aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2011-02-06 17:57:37 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2011-02-06 17:57:37 +0100
commit107ec13506484b10f63424c65f3bb67142265049 (patch)
tree9400d73cf336685b413f4d8273e552c5777f7dbb
parent7f08a51c6615242273f92cf69489d7cb540b7826 (diff)
downloadlogdiag-107ec13506484b10f63424c65f3bb67142265049.tar.gz
logdiag-107ec13506484b10f63424c65f3bb67142265049.tar.xz
logdiag-107ec13506484b10f63424c65f3bb67142265049.zip
Fix a memory leak in LdDiagramSymbol.
-rw-r--r--liblogdiag/ld-canvas.c16
-rw-r--r--liblogdiag/ld-diagram-symbol.c4
-rw-r--r--liblogdiag/ld-diagram-symbol.h2
3 files changed, 15 insertions, 7 deletions
diff --git a/liblogdiag/ld-canvas.c b/liblogdiag/ld-canvas.c
index 84aaf67..564a838 100644
--- a/liblogdiag/ld-canvas.c
+++ b/liblogdiag/ld-canvas.c
@@ -1022,11 +1022,16 @@ is_object_selected (LdCanvas *self, LdDiagramObject *object)
static LdSymbol *
resolve_diagram_symbol (LdCanvas *self, LdDiagramSymbol *diagram_symbol)
{
+ LdSymbol *symbol;
+ gchar *klass;
+
if (!self->priv->library)
return NULL;
- return ld_library_find_symbol (self->priv->library,
- ld_diagram_symbol_get_class (diagram_symbol));
+ klass = ld_diagram_symbol_get_class (diagram_symbol);
+ symbol = ld_library_find_symbol (self->priv->library, klass);
+ g_free (klass);
+ return symbol;
}
static gboolean
@@ -1789,8 +1794,11 @@ draw_symbol (LdDiagramSymbol *diagram_symbol, DrawData *data)
/* TODO: Resolve this better; draw a cross or whatever. */
if (!symbol)
{
- g_warning ("cannot find symbol `%s' in the library",
- ld_diagram_symbol_get_class (diagram_symbol));
+ gchar *klass;
+
+ klass = ld_diagram_symbol_get_class (diagram_symbol);
+ g_warning ("cannot find symbol `%s' in the library", klass);
+ g_free (klass);
return;
}
diff --git a/liblogdiag/ld-diagram-symbol.c b/liblogdiag/ld-diagram-symbol.c
index 370d6ec..8307ef4 100644
--- a/liblogdiag/ld-diagram-symbol.c
+++ b/liblogdiag/ld-diagram-symbol.c
@@ -116,10 +116,10 @@ ld_diagram_symbol_new (JsonObject *storage)
*
* Return value: the class of the symbol.
*/
-const gchar *
+gchar *
ld_diagram_symbol_get_class (LdDiagramSymbol *self)
{
- const gchar *klass;
+ gchar *klass;
g_return_val_if_fail (LD_IS_DIAGRAM_SYMBOL (self), NULL);
g_object_get (self, "class", &klass, NULL);
diff --git a/liblogdiag/ld-diagram-symbol.h b/liblogdiag/ld-diagram-symbol.h
index f2e60e9..d96c0f0 100644
--- a/liblogdiag/ld-diagram-symbol.h
+++ b/liblogdiag/ld-diagram-symbol.h
@@ -53,7 +53,7 @@ struct _LdDiagramSymbolClass
GType ld_diagram_symbol_get_type (void) G_GNUC_CONST;
LdDiagramSymbol *ld_diagram_symbol_new (JsonObject *storage);
-const gchar *ld_diagram_symbol_get_class (LdDiagramSymbol *self);
+gchar *ld_diagram_symbol_get_class (LdDiagramSymbol *self);
void ld_diagram_symbol_set_class (LdDiagramSymbol *self, const gchar *klass);