+2000-04-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * garray.c, glib.h: Added g_(array|ptr_array|byte_array)_sized_new
+ functions, that reserve a certain amount of memeory for the array
+ at creation time to avoid reallocation. Fixes bug #6707 from
+ Charles Kerr <ckerr@osserver1.nssl.noaa.gov>.
+
+ * glib.h, gqueue.c, tests/queue-test.c (main): Renamed
+ g_queue_create to g_queue_new in conformance to all other GLib
+ data types.
+
2000-04-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* grand.c (g_rand_new): Fixed bug. Thanks to Marko Kreen
+2000-04-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * garray.c, glib.h: Added g_(array|ptr_array|byte_array)_sized_new
+ functions, that reserve a certain amount of memeory for the array
+ at creation time to avoid reallocation. Fixes bug #6707 from
+ Charles Kerr <ckerr@osserver1.nssl.noaa.gov>.
+
+ * glib.h, gqueue.c, tests/queue-test.c (main): Renamed
+ g_queue_create to g_queue_new in conformance to all other GLib
+ data types.
+
2000-04-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* grand.c (g_rand_new): Fixed bug. Thanks to Marko Kreen
+2000-04-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * garray.c, glib.h: Added g_(array|ptr_array|byte_array)_sized_new
+ functions, that reserve a certain amount of memeory for the array
+ at creation time to avoid reallocation. Fixes bug #6707 from
+ Charles Kerr <ckerr@osserver1.nssl.noaa.gov>.
+
+ * glib.h, gqueue.c, tests/queue-test.c (main): Renamed
+ g_queue_create to g_queue_new in conformance to all other GLib
+ data types.
+
2000-04-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* grand.c (g_rand_new): Fixed bug. Thanks to Marko Kreen
+2000-04-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * garray.c, glib.h: Added g_(array|ptr_array|byte_array)_sized_new
+ functions, that reserve a certain amount of memeory for the array
+ at creation time to avoid reallocation. Fixes bug #6707 from
+ Charles Kerr <ckerr@osserver1.nssl.noaa.gov>.
+
+ * glib.h, gqueue.c, tests/queue-test.c (main): Renamed
+ g_queue_create to g_queue_new in conformance to all other GLib
+ data types.
+
2000-04-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* grand.c (g_rand_new): Fixed bug. Thanks to Marko Kreen
+2000-04-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * garray.c, glib.h: Added g_(array|ptr_array|byte_array)_sized_new
+ functions, that reserve a certain amount of memeory for the array
+ at creation time to avoid reallocation. Fixes bug #6707 from
+ Charles Kerr <ckerr@osserver1.nssl.noaa.gov>.
+
+ * glib.h, gqueue.c, tests/queue-test.c (main): Renamed
+ g_queue_create to g_queue_new in conformance to all other GLib
+ data types.
+
2000-04-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* grand.c (g_rand_new): Fixed bug. Thanks to Marko Kreen
+2000-04-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * garray.c, glib.h: Added g_(array|ptr_array|byte_array)_sized_new
+ functions, that reserve a certain amount of memeory for the array
+ at creation time to avoid reallocation. Fixes bug #6707 from
+ Charles Kerr <ckerr@osserver1.nssl.noaa.gov>.
+
+ * glib.h, gqueue.c, tests/queue-test.c (main): Renamed
+ g_queue_create to g_queue_new in conformance to all other GLib
+ data types.
+
2000-04-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* grand.c (g_rand_new): Fixed bug. Thanks to Marko Kreen
+2000-04-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * garray.c, glib.h: Added g_(array|ptr_array|byte_array)_sized_new
+ functions, that reserve a certain amount of memeory for the array
+ at creation time to avoid reallocation. Fixes bug #6707 from
+ Charles Kerr <ckerr@osserver1.nssl.noaa.gov>.
+
+ * glib.h, gqueue.c, tests/queue-test.c (main): Renamed
+ g_queue_create to g_queue_new in conformance to all other GLib
+ data types.
+
2000-04-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* grand.c (g_rand_new): Fixed bug. Thanks to Marko Kreen
+2000-04-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * garray.c, glib.h: Added g_(array|ptr_array|byte_array)_sized_new
+ functions, that reserve a certain amount of memeory for the array
+ at creation time to avoid reallocation. Fixes bug #6707 from
+ Charles Kerr <ckerr@osserver1.nssl.noaa.gov>.
+
+ * glib.h, gqueue.c, tests/queue-test.c (main): Renamed
+ g_queue_create to g_queue_new in conformance to all other GLib
+ data types.
+
2000-04-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* grand.c (g_rand_new): Fixed bug. Thanks to Marko Kreen
gboolean clear,
guint elt_size)
{
+ return (GArray*) g_array_sized_new (zero_terminated, clear, elt_size, 0);
+}
+
+GArray* g_array_sized_new (gboolean zero_terminated,
+ gboolean clear,
+ guint elt_size,
+ guint reserved_size)
+{
GRealArray *array;
G_LOCK (array_mem_chunk);
array->clear = (clear ? 1 : 0);
array->elt_size = elt_size;
- if (array->zero_terminated)
+ if (array->zero_terminated || reserved_size != 0)
{
- g_array_maybe_expand (array, 0);
- g_array_elt_zero (array, 0, 1);
+ g_array_maybe_expand (array, reserved_size);
+ g_array_zero_terminate(array);
}
return (GArray*) array;
GPtrArray*
g_ptr_array_new (void)
{
+ return g_ptr_array_sized_new (0);
+}
+
+GPtrArray*
+g_ptr_array_sized_new (guint reserved_size)
+{
GRealPtrArray *array;
G_LOCK (ptr_array_mem_chunk);
array->len = 0;
array->alloc = 0;
- return (GPtrArray*) array;
+ if (reserved_size != 0)
+ g_ptr_array_maybe_expand (array, reserved_size);
+
+ return (GPtrArray*) array;
}
void
GByteArray* g_byte_array_new (void)
{
- return (GByteArray*) g_array_new (FALSE, FALSE, 1);
+ return (GByteArray*) g_array_sized_new (FALSE, FALSE, 1, 0);
+}
+
+GByteArray* g_byte_array_sized_new (guint reserved_size)
+{
+ return (GByteArray*) g_array_sized_new (FALSE, FALSE, 1, reserved_size);
}
void g_byte_array_free (GByteArray *array,
GArray* g_array_new (gboolean zero_terminated,
gboolean clear,
guint element_size);
+GArray* g_array_sized_new (gboolean zero_terminated,
+ gboolean clear,
+ guint element_size,
+ guint reserved_size);
void g_array_free (GArray *array,
gboolean free_segment);
GArray* g_array_append_vals (GArray *array,
*/
#define g_ptr_array_index(array,index) (array->pdata)[index]
GPtrArray* g_ptr_array_new (void);
+GPtrArray* g_ptr_array_sized_new (guint reserved_size);
void g_ptr_array_free (GPtrArray *array,
gboolean free_seg);
void g_ptr_array_set_size (GPtrArray *array,
*/
GByteArray* g_byte_array_new (void);
+GByteArray* g_byte_array_sized_new (guint reserved_size);
void g_byte_array_free (GByteArray *array,
gboolean free_segment);
GByteArray* g_byte_array_append (GByteArray *array,
gboolean clear,
guint elt_size)
{
+ return (GArray*) g_array_sized_new (zero_terminated, clear, elt_size, 0);
+}
+
+GArray* g_array_sized_new (gboolean zero_terminated,
+ gboolean clear,
+ guint elt_size,
+ guint reserved_size)
+{
GRealArray *array;
G_LOCK (array_mem_chunk);
array->clear = (clear ? 1 : 0);
array->elt_size = elt_size;
- if (array->zero_terminated)
+ if (array->zero_terminated || reserved_size != 0)
{
- g_array_maybe_expand (array, 0);
- g_array_elt_zero (array, 0, 1);
+ g_array_maybe_expand (array, reserved_size);
+ g_array_zero_terminate(array);
}
return (GArray*) array;
GPtrArray*
g_ptr_array_new (void)
{
+ return g_ptr_array_sized_new (0);
+}
+
+GPtrArray*
+g_ptr_array_sized_new (guint reserved_size)
+{
GRealPtrArray *array;
G_LOCK (ptr_array_mem_chunk);
array->len = 0;
array->alloc = 0;
- return (GPtrArray*) array;
+ if (reserved_size != 0)
+ g_ptr_array_maybe_expand (array, reserved_size);
+
+ return (GPtrArray*) array;
}
void
GByteArray* g_byte_array_new (void)
{
- return (GByteArray*) g_array_new (FALSE, FALSE, 1);
+ return (GByteArray*) g_array_sized_new (FALSE, FALSE, 1, 0);
+}
+
+GByteArray* g_byte_array_sized_new (guint reserved_size)
+{
+ return (GByteArray*) g_array_sized_new (FALSE, FALSE, 1, reserved_size);
}
void g_byte_array_free (GByteArray *array,
GArray* g_array_new (gboolean zero_terminated,
gboolean clear,
guint element_size);
+GArray* g_array_sized_new (gboolean zero_terminated,
+ gboolean clear,
+ guint element_size,
+ guint reserved_size);
void g_array_free (GArray *array,
gboolean free_segment);
GArray* g_array_append_vals (GArray *array,
*/
#define g_ptr_array_index(array,index) (array->pdata)[index]
GPtrArray* g_ptr_array_new (void);
+GPtrArray* g_ptr_array_sized_new (guint reserved_size);
void g_ptr_array_free (GPtrArray *array,
gboolean free_seg);
void g_ptr_array_set_size (GPtrArray *array,
*/
GByteArray* g_byte_array_new (void);
+GByteArray* g_byte_array_sized_new (guint reserved_size);
void g_byte_array_free (GByteArray *array,
gboolean free_segment);
GByteArray* g_byte_array_append (GByteArray *array,