X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=types%2Ftypes.c;h=7369f30d09ffb5a272c3d54f14e5466ac3b005b2;hp=80ba4eae69a03f809ae6a768db521beb23e4bdfd;hb=312623540c466defab45503fbe0ce7ec79dcce85;hpb=78af2bcd1a8236a26371d7638ab7acb2d41b6807 diff --git a/types/types.c b/types/types.c index 80ba4eae..7369f30d 100644 --- a/types/types.c +++ b/types/types.c @@ -1,5 +1,5 @@ /* - * declarations.c + * types.c * * BabelTrace - Converter * @@ -255,6 +255,8 @@ void declaration_ref(struct declaration *declaration) void declaration_unref(struct declaration *declaration) { + if (!declaration) + return; if (!--declaration->ref) declaration->declaration_free(declaration); } @@ -266,6 +268,8 @@ void definition_ref(struct definition *definition) void definition_unref(struct definition *definition) { + if (!definition) + return; if (!--definition->ref) definition->declaration->definition_free(definition); } @@ -465,6 +469,30 @@ static struct definition_scope * return scope; } +GQuark new_definition_path(struct definition_scope *parent_scope, GQuark field_name) +{ + GQuark path; + GString *str; + gchar *c_str; + int i; + + str = g_string_new(""); + if (parent_scope) { + for (i = 0; i < parent_scope->scope_path->len; i++) { + GQuark q = g_array_index(parent_scope->scope_path, + GQuark, i); + + g_string_append(str, g_quark_to_string(q)); + g_string_append(str, "."); + } + } + g_string_append(str, g_quark_to_string(field_name)); + c_str = g_string_free(str, FALSE); + path = g_quark_from_string(c_str); + g_free(c_str); + return path; +} + struct definition_scope * new_definition_scope(struct definition_scope *parent_scope, GQuark field_name) @@ -508,6 +536,7 @@ void append_scope_path(const char *path, GArray *q) quark = g_quark_from_string(str); g_array_append_val(q, quark); g_free(str); + ptrend++; /* skip current dot */ } /* last. Check for trailing dot (and discard). */ if (ptrbegin[0] != '\0') {