mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-07-30 13:53:30 +02:00
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:
@@ -2117,6 +2117,9 @@ g_string_chunk_free
|
||||
GArray
|
||||
g_array_new
|
||||
g_array_sized_new
|
||||
g_array_ref
|
||||
g_array_unref
|
||||
g_array_get_element_size
|
||||
g_array_append_val
|
||||
g_array_append_vals
|
||||
g_array_prepend_val
|
||||
@@ -2139,6 +2142,10 @@ g_array_free
|
||||
GPtrArray
|
||||
g_ptr_array_new
|
||||
g_ptr_array_sized_new
|
||||
g_ptr_array_new_with_free_func
|
||||
g_ptr_array_set_free_func
|
||||
g_ptr_array_ref
|
||||
g_ptr_array_unref
|
||||
g_ptr_array_add
|
||||
g_ptr_array_remove
|
||||
g_ptr_array_remove_index
|
||||
@@ -2160,6 +2167,8 @@ g_ptr_array_foreach
|
||||
GByteArray
|
||||
g_byte_array_new
|
||||
g_byte_array_sized_new
|
||||
g_byte_array_ref
|
||||
g_byte_array_unref
|
||||
g_byte_array_append
|
||||
g_byte_array_prepend
|
||||
g_byte_array_remove_index
|
||||
|
@@ -69,7 +69,7 @@ added to the #GArray.
|
||||
|
||||
<!-- ##### FUNCTION g_array_new ##### -->
|
||||
<para>
|
||||
Creates a new #GArray.
|
||||
Creates a new #GArray with a reference count of 1.
|
||||
</para>
|
||||
|
||||
@zero_terminated: %TRUE if the array should have an extra element at the end
|
||||
@@ -83,9 +83,9 @@ when they are allocated.
|
||||
<!-- ##### FUNCTION g_array_sized_new ##### -->
|
||||
<para>
|
||||
Creates a new #GArray with @reserved_size elements
|
||||
preallocated. This avoids frequent reallocation, if you are going to
|
||||
add many elements to the array. Note however that the size of the
|
||||
array is still 0.
|
||||
preallocated and a reference count of 1. This avoids frequent reallocation,
|
||||
if you are going to add many elements to the array. Note however that the
|
||||
size of the array is still 0.
|
||||
</para>
|
||||
|
||||
@zero_terminated: %TRUE if the array should have an extra element at the end with all bits cleared.
|
||||
@@ -95,6 +95,32 @@ array is still 0.
|
||||
@Returns: the new #GArray.
|
||||
|
||||
|
||||
<!-- ##### FUNCTION g_array_ref ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@array:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION g_array_unref ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@array:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION g_array_get_element_size ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@array:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### MACRO g_array_append_val ##### -->
|
||||
<para>
|
||||
Adds the value on to the end of the array.
|
||||
@@ -292,8 +318,11 @@ If the array was created with @clear_ set to %TRUE, the new elements are set to
|
||||
<para>
|
||||
Frees the memory allocated for the #GArray.
|
||||
If @free_segment is %TRUE it frees the memory block holding the elements
|
||||
as well. Pass %FALSE if you want to free the #GArray wrapper but preserve
|
||||
the underlying array for use elsewhere.
|
||||
as well and also each element if @array has a @element_free_func set.
|
||||
Pass %FALSE if you want to free the #GArray wrapper but preserve
|
||||
the underlying array for use elsewhere. If the reference count of @array
|
||||
is greater than one, the #GArray wrapper is preserved but the size of
|
||||
@array will be set to zero.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
|
@@ -63,7 +63,7 @@ added to the #GByteArray.
|
||||
|
||||
<!-- ##### FUNCTION g_byte_array_new ##### -->
|
||||
<para>
|
||||
Creates a new #GByteArray.
|
||||
Creates a new #GByteArray with a reference count of 1.
|
||||
</para>
|
||||
|
||||
@Returns: the new #GByteArray.
|
||||
@@ -80,6 +80,23 @@ the array. Note however that the size of the array is still 0.
|
||||
@Returns: the new #GByteArray.
|
||||
|
||||
|
||||
<!-- ##### FUNCTION g_byte_array_ref ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@array:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION g_byte_array_unref ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@array:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION g_byte_array_append ##### -->
|
||||
<para>
|
||||
Adds the given bytes to the end of the #GByteArray.
|
||||
@@ -181,7 +198,9 @@ Sets the size of the #GByteArray, expanding it if necessary.
|
||||
<!-- ##### FUNCTION g_byte_array_free ##### -->
|
||||
<para>
|
||||
Frees the memory allocated by the #GByteArray.
|
||||
If @free_segment is %TRUE it frees the actual byte data.
|
||||
If @free_segment is %TRUE it frees the actual byte data. If the reference
|
||||
count of @array is greater than one, the #GByteArray wrapper is preserved but
|
||||
the size of @array will be set to zero.
|
||||
</para>
|
||||
|
||||
@array: a #GByteArray.
|
||||
|
@@ -73,7 +73,7 @@ Contains the public fields of a pointer array.
|
||||
|
||||
<!-- ##### FUNCTION g_ptr_array_new ##### -->
|
||||
<para>
|
||||
Creates a new #GPtrArray.
|
||||
Creates a new #GPtrArray with a reference count of 1.
|
||||
</para>
|
||||
|
||||
@Returns: the new #GPtrArray.
|
||||
@@ -82,15 +82,50 @@ Creates a new #GPtrArray.
|
||||
<!-- ##### FUNCTION g_ptr_array_sized_new ##### -->
|
||||
<para>
|
||||
Creates a new #GPtrArray with @reserved_size pointers
|
||||
preallocated. This avoids frequent reallocation, if you are going to
|
||||
add many pointers to the array. Note however that the size of the
|
||||
array is still 0.
|
||||
preallocated and a reference count of 1. This avoids frequent reallocation,
|
||||
if you are going to add many pointers to the array. Note however that the size
|
||||
of the array is still 0.
|
||||
</para>
|
||||
|
||||
@reserved_size: number of pointers preallocated.
|
||||
@Returns: the new #GPtrArray.
|
||||
|
||||
|
||||
<!-- ##### FUNCTION g_ptr_array_new_with_free_func ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@element_free_func:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION g_ptr_array_set_free_func ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@array:
|
||||
@element_free_func:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION g_ptr_array_ref ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@array:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION g_ptr_array_unref ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@array:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION g_ptr_array_add ##### -->
|
||||
<para>
|
||||
Adds a pointer to the end of the pointer array.
|
||||
@@ -105,6 +140,8 @@ The array will grow in size automatically if necessary.
|
||||
<para>
|
||||
Removes the first occurrence of the given pointer from the pointer array.
|
||||
The following elements are moved down one place.
|
||||
If @array has a non-%NULL #GDestroyNotify function it is called for
|
||||
the removed element.
|
||||
</para>
|
||||
<para>
|
||||
It returns %TRUE if the pointer was removed, or %FALSE if the pointer
|
||||
@@ -121,6 +158,8 @@ in the array.
|
||||
<para>
|
||||
Removes the pointer at the given index from the pointer array.
|
||||
The following elements are moved down one place.
|
||||
If @array has a non-%NULL #GDestroyNotify function it is called for
|
||||
the removed element.
|
||||
</para>
|
||||
|
||||
@array: a #GPtrArray.
|
||||
@@ -134,6 +173,8 @@ Removes the first occurrence of the given pointer from the pointer array.
|
||||
The last element in the array is used to fill in the space, so this function
|
||||
does not preserve the order of the array. But it is faster than
|
||||
g_ptr_array_remove().
|
||||
If @array has a non-%NULL #GDestroyNotify function it is called for
|
||||
the removed element.
|
||||
</para>
|
||||
<para>
|
||||
It returns %TRUE if the pointer was removed, or %FALSE if the pointer
|
||||
@@ -151,6 +192,8 @@ Removes the pointer at the given index from the pointer array.
|
||||
The last element in the array is used to fill in the space, so this function
|
||||
does not preserve the order of the array. But it is faster than
|
||||
g_ptr_array_remove_index().
|
||||
If @array has a non-%NULL #GDestroyNotify function it is called for
|
||||
the removed element.
|
||||
</para>
|
||||
|
||||
@array: a #GPtrArray.
|
||||
@@ -162,6 +205,8 @@ g_ptr_array_remove_index().
|
||||
<para>
|
||||
Removes the given number of pointers starting at the given index from a
|
||||
#GPtrArray. The following elements are moved to close the gap.
|
||||
If @array has a non-%NULL #GDestroyNotify function it is called for
|
||||
the removed elements.
|
||||
</para>
|
||||
|
||||
@array: a @GPtrArray.
|
||||
@@ -228,14 +273,17 @@ Returns the pointer at the given index of the pointer array.
|
||||
<!-- ##### FUNCTION g_ptr_array_free ##### -->
|
||||
<para>
|
||||
Frees the memory allocated for the #GPtrArray.
|
||||
If @free_segment is %TRUE it frees the memory block holding the elements
|
||||
If @free_seg is %TRUE it frees the memory block holding the elements
|
||||
as well. Pass %FALSE if you want to free the #GPtrArray wrapper but preserve
|
||||
the underlying array for use elsewhere.
|
||||
the underlying array for use elsewhere. If the reference count of @array
|
||||
is greater than one, the #GPtrArray wrapper is preserved but the size of
|
||||
@array will be set to zero.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
If array contents point to dynamically-allocated memory, they should be freed
|
||||
separately.
|
||||
If array contents point to dynamically-allocated memory, they should
|
||||
be freed separately if @free_seg is %TRUE and no #GDestroyNotify
|
||||
function has been set for @array.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
|
Reference in New Issue
Block a user