< prev index next >

modules/javafx.media/src/main/native/gstreamer/3rd_party/glib/glib-2.42.1/glib/garray.c

Print this page
rev 10250 : imported patch 9-cpu-1701.patch


 978 
 979 /**
 980  * g_ptr_array_set_free_func:
 981  * @array: A #GPtrArray
 982  * @element_free_func: (allow-none): A function to free elements with
 983  *     destroy @array or %NULL
 984  *
 985  * Sets a function for freeing each element when @array is destroyed
 986  * either via g_ptr_array_unref(), when g_ptr_array_free() is called
 987  * with @free_segment set to %TRUE or when removing elements.
 988  *
 989  * Since: 2.22
 990  */
 991 void
 992 g_ptr_array_set_free_func (GPtrArray      *array,
 993                            GDestroyNotify  element_free_func)
 994 {
 995   GRealPtrArray *rarray = (GRealPtrArray *)array;
 996 
 997   g_return_if_fail (array);




 998 
 999   rarray->element_free_func = element_free_func;
1000 }
1001 
1002 /**
1003  * g_ptr_array_ref:
1004  * @array: a #GPtrArray
1005  *
1006  * Atomically increments the reference count of @array by one.
1007  * This function is thread-safe and may be called from any thread.
1008  *
1009  * Returns: The passed in #GPtrArray
1010  *
1011  * Since: 2.22
1012  */
1013 GPtrArray*
1014 g_ptr_array_ref (GPtrArray *array)
1015 {
1016   GRealPtrArray *rarray = (GRealPtrArray *)array;
1017 


1576 /**
1577  * g_byte_array_new_take:
1578  * @data: (transfer full) (array length=len): byte data for the array
1579  * @len: length of @data
1580  *
1581  * Create byte array containing the data. The data will be owned by the array
1582  * and will be freed with g_free(), i.e. it could be allocated using g_strdup().
1583  *
1584  * Since: 2.32
1585  *
1586  * Returns: (transfer full): a new #GByteArray
1587  */
1588 GByteArray*
1589 g_byte_array_new_take (guint8 *data,
1590                        gsize   len)
1591 {
1592   GByteArray *array;
1593   GRealArray *real;
1594 
1595   array = g_byte_array_new ();




1596   real = (GRealArray *)array;
1597   g_assert (real->data == NULL);
1598   g_assert (real->len == 0);
1599 
1600   real->data = data;
1601   real->len = len;
1602   real->alloc = len;
1603 
1604   return array;
1605 }
1606 
1607 /**
1608  * g_byte_array_sized_new:
1609  * @reserved_size: number of bytes preallocated
1610  *
1611  * Creates a new #GByteArray with @reserved_size bytes preallocated.
1612  * This avoids frequent reallocation, if you are going to add many
1613  * bytes to the array. Note however that the size of the array is still
1614  * 0.
1615  *




 978 
 979 /**
 980  * g_ptr_array_set_free_func:
 981  * @array: A #GPtrArray
 982  * @element_free_func: (allow-none): A function to free elements with
 983  *     destroy @array or %NULL
 984  *
 985  * Sets a function for freeing each element when @array is destroyed
 986  * either via g_ptr_array_unref(), when g_ptr_array_free() is called
 987  * with @free_segment set to %TRUE or when removing elements.
 988  *
 989  * Since: 2.22
 990  */
 991 void
 992 g_ptr_array_set_free_func (GPtrArray      *array,
 993                            GDestroyNotify  element_free_func)
 994 {
 995   GRealPtrArray *rarray = (GRealPtrArray *)array;
 996 
 997   g_return_if_fail (array);
 998 #ifdef GSTREAMER_LITE
 999   if (array == NULL)
1000     return;
1001 #endif // GSTREAMER_LITE
1002 
1003   rarray->element_free_func = element_free_func;
1004 }
1005 
1006 /**
1007  * g_ptr_array_ref:
1008  * @array: a #GPtrArray
1009  *
1010  * Atomically increments the reference count of @array by one.
1011  * This function is thread-safe and may be called from any thread.
1012  *
1013  * Returns: The passed in #GPtrArray
1014  *
1015  * Since: 2.22
1016  */
1017 GPtrArray*
1018 g_ptr_array_ref (GPtrArray *array)
1019 {
1020   GRealPtrArray *rarray = (GRealPtrArray *)array;
1021 


1580 /**
1581  * g_byte_array_new_take:
1582  * @data: (transfer full) (array length=len): byte data for the array
1583  * @len: length of @data
1584  *
1585  * Create byte array containing the data. The data will be owned by the array
1586  * and will be freed with g_free(), i.e. it could be allocated using g_strdup().
1587  *
1588  * Since: 2.32
1589  *
1590  * Returns: (transfer full): a new #GByteArray
1591  */
1592 GByteArray*
1593 g_byte_array_new_take (guint8 *data,
1594                        gsize   len)
1595 {
1596   GByteArray *array;
1597   GRealArray *real;
1598 
1599   array = g_byte_array_new ();
1600 #ifdef GSTREAMER_LITE
1601   if (array == NULL)
1602     return NULL;
1603 #endif // GSTREAMER_LITE
1604   real = (GRealArray *)array;
1605   g_assert (real->data == NULL);
1606   g_assert (real->len == 0);
1607 
1608   real->data = data;
1609   real->len = len;
1610   real->alloc = len;
1611 
1612   return array;
1613 }
1614 
1615 /**
1616  * g_byte_array_sized_new:
1617  * @reserved_size: number of bytes preallocated
1618  *
1619  * Creates a new #GByteArray with @reserved_size bytes preallocated.
1620  * This avoids frequent reallocation, if you are going to add many
1621  * bytes to the array. Note however that the size of the array is still
1622  * 0.
1623  *


< prev index next >