Bug 580450 – Reference counting and boxed types for arrays

Add reference counting and boxed types for GArray, GByteArray and GPtrArray.

Signed-off-by: Matthias Clasen <mclasen@redhat.com>
This commit is contained in:
David Zeuthen
2009-04-29 11:15:20 -04:00
parent d80e12104f
commit 402847c887
11 changed files with 616 additions and 28 deletions

View File

@@ -274,6 +274,39 @@ g_regex_get_type (void)
return type_id;
}
GType
g_array_get_type (void)
{
static GType type_id = 0;
if (!type_id)
type_id = g_boxed_type_register_static (g_intern_static_string ("GArray"),
(GBoxedCopyFunc) g_array_ref,
(GBoxedFreeFunc) g_array_unref);
return type_id;
}
GType
g_ptr_array_get_type (void)
{
static GType type_id = 0;
if (!type_id)
type_id = g_boxed_type_register_static (g_intern_static_string ("GPtrArray"),
(GBoxedCopyFunc) g_ptr_array_ref,
(GBoxedFreeFunc) g_ptr_array_unref);
return type_id;
}
GType
g_byte_array_get_type (void)
{
static GType type_id = 0;
if (!type_id)
type_id = g_boxed_type_register_static (g_intern_static_string ("GByteArray"),
(GBoxedCopyFunc) g_byte_array_ref,
(GBoxedFreeFunc) g_byte_array_unref);
return type_id;
}
static void
boxed_proxy_value_init (GValue *value)
{

View File

@@ -162,6 +162,30 @@ GType g_boxed_type_register_static (const gchar *name,
* Since: 2.14
*/
#define G_TYPE_REGEX (g_regex_get_type ())
/**
* G_TYPE_ARRAY:
*
* The #GType for a boxed type holding a #GArray reference.
*
* Since: 2.22
*/
#define G_TYPE_ARRAY (g_array_get_type ())
/**
* G_TYPE_BYTE_ARRAY:
*
* The #GType for a boxed type holding a #GByteArray reference.
*
* Since: 2.22
*/
#define G_TYPE_BYTE_ARRAY (g_byte_array_get_type ())
/**
* G_TYPE_PTR_ARRAY:
*
* The #GType for a boxed type holding a #GPtrArray reference.
*
* Since: 2.22
*/
#define G_TYPE_PTR_ARRAY (g_ptr_array_get_type ())
void g_value_take_boxed (GValue *value,
@@ -177,6 +201,9 @@ GType g_date_get_type (void) G_GNUC_CONST;
GType g_strv_get_type (void) G_GNUC_CONST;
GType g_gstring_get_type (void) G_GNUC_CONST;
GType g_hash_table_get_type (void) G_GNUC_CONST;
GType g_array_get_type (void) G_GNUC_CONST;
GType g_byte_array_get_type (void) G_GNUC_CONST;
GType g_ptr_array_get_type (void) G_GNUC_CONST;
GType g_regex_get_type (void) G_GNUC_CONST;
/**

View File

@@ -20,6 +20,9 @@ g_date_get_type G_GNUC_CONST
g_gstring_get_type G_GNUC_CONST
g_strv_get_type G_GNUC_CONST
g_hash_table_get_type G_GNUC_CONST
g_array_get_type G_GNUC_CONST
g_byte_array_get_type G_GNUC_CONST
g_ptr_array_get_type G_GNUC_CONST
g_regex_get_type G_GNUC_CONST
g_closure_get_type G_GNUC_CONST
g_value_get_type G_GNUC_CONST