From 6f3c4bc6ec571dcca8e25b9f82a0c2e72310900c Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Sun, 8 Jul 2018 21:48:30 +0200
Subject: Changed the type of namespace separators.

---
 plugins/dex/class.c         |  5 +++--
 plugins/dexbnf/type.c       |  5 ++++-
 plugins/itanium/abi.c       |  2 +-
 plugins/itanium/component.c |  4 ++--
 src/analysis/routine.c      |  7 +++++--
 src/analysis/routine.h      |  2 +-
 src/analysis/type-int.h     |  2 +-
 src/analysis/type.c         | 15 +++++++++++++--
 src/analysis/type.h         |  2 +-
 9 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/plugins/dex/class.c b/plugins/dex/class.c
index a674b98..d6af91b 100644
--- a/plugins/dex/class.c
+++ b/plugins/dex/class.c
@@ -25,6 +25,7 @@
 
 
 #include <malloc.h>
+#include <string.h>
 
 
 #include "dex-int.h"
@@ -313,7 +314,7 @@ GDexClass *g_dex_class_new(GDexFormat *format, const class_def_item *def)
             routine = g_dex_method_get_routine(method);
 
             g_object_ref(G_OBJECT(ctype));
-            g_binary_routine_set_namespace(routine, ctype, ".");
+            g_binary_routine_set_namespace(routine, ctype, strdup("."));
 
             g_binary_format_add_symbol(base, G_BIN_SYMBOL(routine));
 
@@ -339,7 +340,7 @@ GDexClass *g_dex_class_new(GDexFormat *format, const class_def_item *def)
             routine = g_dex_method_get_routine(method);
 
             g_object_ref(G_OBJECT(ctype));
-            g_binary_routine_set_namespace(routine, ctype, ".");
+            g_binary_routine_set_namespace(routine, ctype, strdup("."));
 
             g_binary_format_add_symbol(base, G_BIN_SYMBOL(routine));
 
diff --git a/plugins/dexbnf/type.c b/plugins/dexbnf/type.c
index a6ce838..5a0d82c 100644
--- a/plugins/dexbnf/type.c
+++ b/plugins/dexbnf/type.c
@@ -24,6 +24,9 @@
 #include "type.h"
 
 
+#include <string.h>
+
+
 #include <analysis/types/basic.h>
 #include <analysis/types/cse.h>
 #include <analysis/types/encaps.h>
@@ -113,7 +116,7 @@ static GDataType *dtd_full_class_name(input_buffer *buffer)
 
         result = g_class_enum_type_new(CET_CLASS, name);
 
-        g_data_type_set_namespace(result, ns, ".");
+        g_data_type_set_namespace(result, ns, strdup("."));
 
     }
     while (1);
diff --git a/plugins/itanium/abi.c b/plugins/itanium/abi.c
index fa661dc..8891446 100644
--- a/plugins/itanium/abi.c
+++ b/plugins/itanium/abi.c
@@ -3330,7 +3330,7 @@ static itanium_component *itd_substitution(GItaniumDemangling *context)
                 else
                 {
                     type = g_class_enum_type_new(CET_CLASS, strdup(stdinfo->class));
-                    g_data_type_set_namespace(type, std, "::");
+                    g_data_type_set_namespace(type, std, strdup("::"));
                 }
 
                 result = itd_make_type(type);
diff --git a/plugins/itanium/component.c b/plugins/itanium/component.c
index e7315e8..8c29861 100644
--- a/plugins/itanium/component.c
+++ b/plugins/itanium/component.c
@@ -1325,7 +1325,7 @@ static void itd_prepend_namespace_to_type(GDataType *type, GDataType *ns)
     existing = g_data_type_get_namespace(type);
 
     if (existing == NULL)
-        g_data_type_set_namespace(type, ns, "::");
+        g_data_type_set_namespace(type, ns, strdup("::"));
 
     else
     {
@@ -1869,7 +1869,7 @@ GBinRoutine *itd_translate_component_to_routine(const itanium_component *comp)
 
             }
 
-            g_binary_routine_set_namespace(result, ns, "::");
+            g_binary_routine_set_namespace(result, ns, strdup("::"));
 
             break;
 
diff --git a/src/analysis/routine.c b/src/analysis/routine.c
index d223165..19782c7 100644
--- a/src/analysis/routine.c
+++ b/src/analysis/routine.c
@@ -51,7 +51,7 @@ struct _GBinRoutine
     GDataType *ret_type;                    /* Type retourné               */
 
     GDataType *namespace;                   /* Espace de noms / classe     */
-    const char *ns_sep;                     /* Séparateur d'éléments       */
+    char *ns_sep;                           /* Séparateur d'éléments       */
     char *name;                             /* Désignation humaine         */
     GDataType *full_name;                   /* Désignation très complète   */
 
@@ -250,11 +250,14 @@ void g_binary_routine_set_type(GBinRoutine *routine, RoutineType type)
 *                                                                             *
 ******************************************************************************/
 
-void g_binary_routine_set_namespace(GBinRoutine *routine, GDataType *namespace, const char *sep)
+void g_binary_routine_set_namespace(GBinRoutine *routine, GDataType *namespace, char *sep)
 {
     if (routine->namespace != NULL)
         g_object_unref(G_OBJECT(routine->namespace));
 
+    if (routine->ns_sep != NULL)
+        free(routine->ns_sep);
+
     routine->namespace = namespace;
     routine->ns_sep = sep;
 
diff --git a/src/analysis/routine.h b/src/analysis/routine.h
index 9671c92..e1512a8 100644
--- a/src/analysis/routine.h
+++ b/src/analysis/routine.h
@@ -75,7 +75,7 @@ GBinRoutine *g_binary_routine_new_constructor(GDataType *);
 void g_binary_routine_set_type(GBinRoutine *, RoutineType);
 
 /* Définit le groupe d'appartenance d'une routine donnée. */
-void g_binary_routine_set_namespace(GBinRoutine *, GDataType *, const char *);
+void g_binary_routine_set_namespace(GBinRoutine *, GDataType *, char *);
 
 /* Fournit le groupe d'appartenance d'une routine donnée. */
 GDataType *g_binary_routine_get_namespace(const GBinRoutine *);
diff --git a/src/analysis/type-int.h b/src/analysis/type-int.h
index 3c34680..08b6338 100644
--- a/src/analysis/type-int.h
+++ b/src/analysis/type-int.h
@@ -49,7 +49,7 @@ struct _GDataType
     GObject parent;                         /* A laisser en premier        */
 
     GDataType *namespace;                   /* Espace de noms / classe     */
-    const char *ns_sep;                     /* Séparateur d'éléments       */
+    char *ns_sep;                           /* Séparateur d'éléments       */
 
     TypeQualifier qualifiers;               /* Eventuels qualificatifs     */
 
diff --git a/src/analysis/type.c b/src/analysis/type.c
index 5c1878f..d0ab4f5 100644
--- a/src/analysis/type.c
+++ b/src/analysis/type.c
@@ -25,6 +25,7 @@
 
 
 #include <malloc.h>
+#include <string.h>
 
 
 #include "type-int.h"
@@ -130,6 +131,9 @@ static void g_data_type_dispose(GDataType *type)
 
 static void g_data_type_finalize(GDataType *type)
 {
+    if (type->ns_sep != NULL)
+        free(type->ns_sep);
+
     G_OBJECT_CLASS(g_data_type_parent_class)->finalize(G_OBJECT(type));
 
 }
@@ -152,6 +156,7 @@ GDataType *g_data_type_dup(const GDataType *type)
     GDataType *result;                      /* Copie à retourner           */
     GDataTypeClass *class;                  /* Classe du type              */
     GDataType *ns;                          /* Eventuel espace de noms     */
+    char *ns_sep;                           /* Séparation des espaces      */
 
     class = G_DATA_TYPE_GET_CLASS(type);
 
@@ -160,7 +165,10 @@ GDataType *g_data_type_dup(const GDataType *type)
     if (type->namespace != NULL)
     {
         ns = g_data_type_dup(type->namespace);
-        g_data_type_set_namespace(result, ns, type->ns_sep);
+        ns_sep = type->ns_sep != NULL ? strdup(type->ns_sep) : NULL;
+
+        g_data_type_set_namespace(result, ns, ns_sep);
+
     }
 
     result->qualifiers = type->qualifiers;
@@ -232,11 +240,14 @@ char *g_data_type_to_string(const GDataType *type, bool include)
 *                                                                             *
 ******************************************************************************/
 
-void g_data_type_set_namespace(GDataType *type, GDataType *namespace, const char *sep)
+void g_data_type_set_namespace(GDataType *type, GDataType *namespace, char *sep)
 {
     if (type->namespace != NULL)
         g_object_unref(G_OBJECT(type->namespace));
 
+    if (type->ns_sep != NULL)
+        free(type->ns_sep);
+
     type->namespace = namespace;
     type->ns_sep = sep;
 
diff --git a/src/analysis/type.h b/src/analysis/type.h
index a8a9d5f..108256e 100644
--- a/src/analysis/type.h
+++ b/src/analysis/type.h
@@ -70,7 +70,7 @@ GDataType *g_data_type_dup(const GDataType *);
 char *g_data_type_to_string(const GDataType *, bool);
 
 /* Définit le groupe d'appartenance d'un type donné. */
-void g_data_type_set_namespace(GDataType *, GDataType *, const char *);
+void g_data_type_set_namespace(GDataType *, GDataType *, char *);
 
 /* Fournit le groupe d'appartenance d'un type donné. */
 GDataType *g_data_type_get_namespace(const GDataType *);
-- 
cgit v0.11.2-87-g4458