summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/analysis/types/template.c14
-rw-r--r--src/analysis/types/template.h2
2 files changed, 11 insertions, 5 deletions
diff --git a/src/analysis/types/template.c b/src/analysis/types/template.c
index 01e74e7..75879f4 100644
--- a/src/analysis/types/template.c
+++ b/src/analysis/types/template.c
@@ -238,12 +238,15 @@ const char *g_template_type_get_name(GTemplateType *type)
* *
******************************************************************************/
-void g_template_type_set_name(GTemplateType *type, char *name)
+void g_template_type_set_name(GTemplateType *type, const char *name)
{
if (type->name != NULL)
free(type->name);
- type->name = name;
+ if (name == NULL)
+ type->name = NULL;
+ else
+ type->name = strdup(name);
}
@@ -269,12 +272,13 @@ static GDataType *g_template_type_dup(const GTemplateType *type)
result = G_TEMPLATE_TYPE(g_template_type_new());
if (type->name != NULL)
- g_template_type_set_name(result, strdup(type->name));
+ g_template_type_set_name(result, type->name);
for (i = 0; i < type->count; i++)
{
param = g_data_type_dup(type->params[i]);
g_template_type_add_param(result, param);
+ g_object_unref(G_OBJECT(param));
}
return G_DATA_TYPE(result);
@@ -348,7 +352,9 @@ static char *g_template_type_to_string(const GTemplateType *type, bool include)
void g_template_type_add_param(GTemplateType *type, GDataType *param)
{
- type->params = (GDataType **)realloc(type->params, ++type->count * sizeof(GDataType *));
+ g_object_ref(G_OBJECT(param));
+
+ type->params = realloc(type->params, ++type->count * sizeof(GDataType *));
type->params[type->count - 1] = param;
}
diff --git a/src/analysis/types/template.h b/src/analysis/types/template.h
index 02043cd..ec69327 100644
--- a/src/analysis/types/template.h
+++ b/src/analysis/types/template.h
@@ -57,7 +57,7 @@ GDataType *g_template_type_new(void);
const char *g_template_type_get_name(GTemplateType *);
/* Précise la désignation principale du type. */
-void g_template_type_set_name(GTemplateType *, char *);
+void g_template_type_set_name(GTemplateType *, const char *);
/* Ajoute un paramètre à un gabarit. */
void g_template_type_add_param(GTemplateType *, GDataType *);