From: Mathieu Desnoyers Date: Tue, 22 Feb 2011 10:27:45 +0000 (-0500) Subject: Update g array ref X-Git-Tag: v0.1~192 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=fdacfb7382aad4a19dc48f8a0d830ae5b8597498;hp=380d60b1bd3c5d1a709dca3eeb8e718598fed235 Update g array ref Signed-off-by: Mathieu Desnoyers --- diff --git a/include/babeltrace/types.h b/include/babeltrace/types.h index d6ac7924..a315c4c3 100644 --- a/include/babeltrace/types.h +++ b/include/babeltrace/types.h @@ -236,7 +236,8 @@ GArray *enum_int_to_quark_set(const struct type_class_enum *enum_class, /* * Returns a GArray of struct enum_range or NULL. - * Caller must release the GArray with g_array_unref(). + * Callers do _not_ own the returned GArray (and therefore _don't_ need to + * release it). */ GArray *enum_quark_to_range_set(const struct type_class_enum *enum_class, GQuark q); diff --git a/types/enum.c b/types/enum.c index 38a972a9..6ad4d450 100644 --- a/types/enum.c +++ b/types/enum.c @@ -62,8 +62,10 @@ GArray *enum_uint_to_quark_set(const struct type_class_enum *enum_class, g_array_index(ranges, struct enum_range, ranges->len) = iter->range; } } - if (!ranges) + if (!ranges) { ranges = qs; + g_array_ref(ranges); + } return ranges; } @@ -101,8 +103,10 @@ GArray *enum_int_to_quark_set(const struct type_class_enum *enum_class, uint64_t g_array_index(ranges, struct enum_range, ranges->len) = iter->range; } } - if (!ranges) + if (!ranges) { ranges = qs; + g_array_ref(ranges); + } return ranges; }