GBytes: A new type for an immutable set of bytes.

* Represents an immutable reference counted block of memory.
 * This is basically the internal glib GBuffer structure exposed,
   renamed, and with some additional capabilities.
 * The GBytes name comes from python3's immutable 'bytes' type
 * GBytes can be safely used as keys in hash tables, and have
   functions for doing so: g_bytes_hash, g_bytes_equal
 * GByteArray is a mutable form of GBytes, and vice versa. There
   are functions for converting from one to the other efficiently:
   g_bytes_unref_to_array() and g_byte_array_free_to_bytes()
 * Adds g_byte_array_new_take() to support above functions

https://bugzilla.gnome.org/show_bug.cgi?id=663291
This commit is contained in:
Stef Walter
2011-11-11 17:08:26 +01:00
parent 069ec3719c
commit fcc69fd318
25 changed files with 1101 additions and 370 deletions

View File

@@ -127,6 +127,7 @@ G_DEFINE_BOXED_TYPE (GHashTable, g_hash_table, g_hash_table_ref, g_hash_table_un
G_DEFINE_BOXED_TYPE (GArray, g_array, g_array_ref, g_array_unref)
G_DEFINE_BOXED_TYPE (GPtrArray, g_ptr_array,g_ptr_array_ref, g_ptr_array_unref)
G_DEFINE_BOXED_TYPE (GByteArray, g_byte_array, g_byte_array_ref, g_byte_array_unref)
G_DEFINE_BOXED_TYPE (GBytes, g_bytes, g_bytes_ref, g_bytes_unref);
#ifdef ENABLE_REGEX
G_DEFINE_BOXED_TYPE (GRegex, g_regex, g_regex_ref, g_regex_unref)

View File

@@ -132,6 +132,15 @@ typedef gsize GType;
*/
#define G_TYPE_PTR_ARRAY (g_ptr_array_get_type ())
/**
* G_TYPE_BYTES:
*
* The #GType for #GBytes.
*
* Since: 2.32
*/
#define G_TYPE_BYTES (g_bytes_get_type ())
/**
* G_TYPE_VARIANT_TYPE:
*
@@ -225,6 +234,7 @@ 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_bytes_get_type (void) G_GNUC_CONST;
GType g_variant_type_get_gtype (void) G_GNUC_CONST;
GType g_regex_get_type (void) G_GNUC_CONST;
GType g_match_info_get_type (void) G_GNUC_CONST;

View File

@@ -21,6 +21,7 @@ g_strv_get_type
g_hash_table_get_type
g_array_get_type
g_byte_array_get_type
g_bytes_get_type
g_error_get_type
g_ptr_array_get_type
g_regex_get_type