From fdacfb7382aad4a19dc48f8a0d830ae5b8597498 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 22 Feb 2011 05:27:45 -0500 Subject: [PATCH] Update g array ref Signed-off-by: Mathieu Desnoyers --- include/babeltrace/types.h | 3 ++- types/enum.c | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) 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; } -- 2.34.1