diff options
author | Tim Janik <timj@imendio.com> | 2005-11-01 18:10:31 +0000 |
---|---|---|
committer | Tim Janik <timj@src.gnome.org> | 2005-11-01 18:10:31 +0000 |
commit | 0cba1b531d5d28890fa4f48359d4e7adacf2a603 (patch) | |
tree | fa2a88ef5c43b20004851e2b9f3eb14cf10c71f2 /glib/garray.c | |
parent | 3a042a8959501f9e90df41fc31e3167dd7aa6222 (diff) | |
download | glib-0cba1b531d5d28890fa4f48359d4e7adacf2a603.tar.gz |
prepared deprecation of GMemChunk and GAllocator. added g_slice_*() API to
Tue Nov 1 16:24:20 2005 Tim Janik <timj@imendio.com>
* glib/gmem.[hc]: prepared deprecation of GMemChunk and GAllocator.
added g_slice_*() API to allocate and cache small bits of memory.
an actuall allocator implementation for g_slice_*() is still pending.
* glib/gthread.[hc]: changes from a patch by Matthias Clasen.
changed GRealThread list to use in-structure *next; fields instead
of GSList, in order for thread iteration to not depenend on g_slice_*()
indirectly.
_g_thread_mem_private_get():
_g_thread_mem_private_set(): added accessors for private memory,
needed because the ordinary GPrivate implementation relies on GArray
and GSList and therefore indirectly on working g_slice_*() allocations.
* glib/gthread.[hc]:
g_thread_foreach(): new public API function to loop over all existing threads.
* glib/gdataset.c:
* glib/gstring.c:
* glib/gcache.c:
* glib/garray.c:
* glib/gqueue.c:
* glib/gslist.c:
* glib/glist.c:
* glib/ghash.c:
* glib/gtree.c:
* glib/ghook.c:
* glib/gmain.c:
* glib/gnode.c:
removed GAllocator and free list usages and accompanying locks.
use g_slice_*() API to allocate and cache small bits of memory.
* glib/ghook.h: removed GMemChunk field from public API.
* glib/gslist.h:
* glib/glist.h: deprecate allocator API, provide _free1() for consistency.
* glib/gnode.h: deprecate allocator API.
* glib/gmain.c: reordered GPollRec fields so g_slice_free_chain() can
be used for poll rec lists.
* glib/grel.c: removed mem chunk usage, and allocated tuples via g_slice_*().
g_relation_destroy(): free all tuples from the all_tuples hash table,
this effectively maintains the life time track keeping of tuples.
g_relation_delete_tuple(): free tuples which are removed from the
all_tuples hash table. this fixes a temporary leak that was present
in the memchunk code until the destruction of the relation.
Diffstat (limited to 'glib/garray.c')
-rw-r--r-- | glib/garray.c | 37 |
1 files changed, 4 insertions, 33 deletions
diff --git a/glib/garray.c b/glib/garray.c index 54ee05b02..aca3b6afd 100644 --- a/glib/garray.c +++ b/glib/garray.c @@ -70,9 +70,6 @@ static gint g_nearest_pow (gint num) G_GNUC_CONST; static void g_array_maybe_expand (GRealArray *array, gint len); -static GMemChunk *array_mem_chunk = NULL; -G_LOCK_DEFINE_STATIC (array_mem_chunk); - GArray* g_array_new (gboolean zero_terminated, gboolean clear, @@ -86,16 +83,7 @@ GArray* g_array_sized_new (gboolean zero_terminated, guint elt_size, guint reserved_size) { - GRealArray *array; - - G_LOCK (array_mem_chunk); - if (!array_mem_chunk) - array_mem_chunk = g_mem_chunk_new ("array mem chunk", - sizeof (GRealArray), - 1024, G_ALLOC_AND_FREE); - - array = g_chunk_new (GRealArray, array_mem_chunk); - G_UNLOCK (array_mem_chunk); + GRealArray *array = g_slice_new (GRealArray); array->data = NULL; array->len = 0; @@ -129,9 +117,7 @@ g_array_free (GArray *array, else segment = array->data; - G_LOCK (array_mem_chunk); - g_mem_chunk_free (array_mem_chunk, array); - G_UNLOCK (array_mem_chunk); + g_slice_free1 (sizeof (GRealArray), array); return segment; } @@ -380,10 +366,6 @@ struct _GRealPtrArray static void g_ptr_array_maybe_expand (GRealPtrArray *array, gint len); -static GMemChunk *ptr_array_mem_chunk = NULL; -G_LOCK_DEFINE_STATIC (ptr_array_mem_chunk); - - GPtrArray* g_ptr_array_new (void) { @@ -393,16 +375,7 @@ g_ptr_array_new (void) GPtrArray* g_ptr_array_sized_new (guint reserved_size) { - GRealPtrArray *array; - - G_LOCK (ptr_array_mem_chunk); - if (!ptr_array_mem_chunk) - ptr_array_mem_chunk = g_mem_chunk_new ("array mem chunk", - sizeof (GRealPtrArray), - 1024, G_ALLOC_AND_FREE); - - array = g_chunk_new (GRealPtrArray, ptr_array_mem_chunk); - G_UNLOCK (ptr_array_mem_chunk); + GRealPtrArray *array = g_slice_new (GRealPtrArray); array->pdata = NULL; array->len = 0; @@ -430,9 +403,7 @@ g_ptr_array_free (GPtrArray *array, else segment = array->pdata; - G_LOCK (ptr_array_mem_chunk); - g_mem_chunk_free (ptr_array_mem_chunk, array); - G_UNLOCK (ptr_array_mem_chunk); + g_slice_free1 (sizeof (GRealPtrArray), array); return segment; } |