summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Miąsko <tomasz.miasko@gmail.com>2018-02-13 00:00:00 +0000
committerTomasz Miąsko <tomasz.miasko@gmail.com>2018-02-13 14:11:27 +0100
commit75fed99356bbfef17847bc765e916c2d629af956 (patch)
treef4d1c2e1a61b27e3b9f4867a99608049ca65e9b2
parente8e567546282d714729df55d10ca26ec35c71416 (diff)
downloadgobject-introspection-75fed99356bbfef17847bc765e916c2d629af956.tar.gz
Create a new symbol instead of changing its identifier in place.
Also free memory associated with macro name when it is unused.
-rw-r--r--giscanner/scannerparser.y10
-rw-r--r--tests/scanner/regress.h7
2 files changed, 15 insertions, 2 deletions
diff --git a/giscanner/scannerparser.y b/giscanner/scannerparser.y
index db3aef1f..abfbe065 100644
--- a/giscanner/scannerparser.y
+++ b/giscanner/scannerparser.y
@@ -1508,8 +1508,14 @@ object_macro_define
: object_macro constant_expression
{
if ($2->const_int_set || $2->const_boolean_set || $2->const_double_set || $2->const_string != NULL) {
- $2->ident = $1;
- gi_source_scanner_add_symbol (scanner, $2);
+ GISourceSymbol *macro = gi_source_symbol_copy ($2);
+ g_free (macro->ident);
+ macro->ident = $1;
+ gi_source_scanner_add_symbol (scanner, macro);
+ gi_source_symbol_unref (macro);
+ gi_source_symbol_unref ($2);
+ } else {
+ g_free ($1);
gi_source_symbol_unref ($2);
}
}
diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h
index cf0059e4..e1c995a6 100644
--- a/tests/scanner/regress.h
+++ b/tests/scanner/regress.h
@@ -423,6 +423,13 @@ typedef enum
REGRESS_TEST_EVALUE3 = '0'
} RegressTestEnumNoGEnum;
+/**
+ * REGRESS_TEST_EVALUE_DEPRECATED:
+ *
+ * Scanner used to replace %REGRESS_TEST_EVALUE1 with %REGRESS_TEST_EVALUE_DEPRECATED.
+ */
+#define REGRESS_TEST_EVALUE_DEPRECATED REGRESS_TEST_EVALUE1
+
_GI_TEST_EXTERN
const gchar * regress_test_enum_param(RegressTestEnum e);