mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-30 04:44:16 +02:00
removed the GListAllocator type and its g_*_allocator_*() function
Tue Nov 24 09:40:00 1998 Tim Janik <timj@gtk.org> * glib.h: removed the GListAllocator type and its g_*_allocator_*() function variants (which weren't working anyways) in favour of a generic GAllocator type. new functions: g_allocator_new, g_allocator_free, g_slist_push_allocator, g_slist_pop_allocator, g_list_push_allocator, g_list_pop_allocator, g_node_push_allocator and g_node_pop_allocator. * gstring.c: removed bogus slist allocator code. * gtree.c: maintain own list of free tree nodes and don't waste GSLists for that, removed bogus slist allocator code. * glist.c: use GAllocators for node allocation. * gslist.c: use GAllocators for node allocation. * gnode.c: use GAllocators for node allocation. * gdataset.c: cleanups wrt automatic initialization.
This commit is contained in:
46
gmem.c
46
gmem.c
@@ -894,3 +894,49 @@ g_mem_chunk_area_search (GMemArea *a,
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* generic allocators
|
||||
*/
|
||||
struct _GAllocator /* from gmem.c */
|
||||
{
|
||||
gchar *name;
|
||||
guint16 n_preallocs;
|
||||
guint is_unused : 1;
|
||||
guint type : 4;
|
||||
GAllocator *last;
|
||||
GMemChunk *mem_chunk;
|
||||
gpointer dummy; /* implementation specific */
|
||||
};
|
||||
|
||||
GAllocator*
|
||||
g_allocator_new (const gchar *name,
|
||||
guint n_preallocs)
|
||||
{
|
||||
GAllocator *allocator;
|
||||
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
allocator = g_new0 (GAllocator, 1);
|
||||
allocator->name = g_strdup (name);
|
||||
allocator->n_preallocs = CLAMP (n_preallocs, 1, 65535);
|
||||
allocator->is_unused = TRUE;
|
||||
allocator->type = 0;
|
||||
allocator->last = NULL;
|
||||
allocator->mem_chunk = NULL;
|
||||
allocator->dummy = NULL;
|
||||
|
||||
return allocator;
|
||||
}
|
||||
|
||||
void
|
||||
g_allocator_free (GAllocator *allocator)
|
||||
{
|
||||
g_return_if_fail (allocator != NULL);
|
||||
g_return_if_fail (allocator->is_unused == TRUE);
|
||||
|
||||
g_free (allocator->name);
|
||||
if (allocator->mem_chunk)
|
||||
g_mem_chunk_destroy (allocator->mem_chunk);
|
||||
|
||||
g_free (allocator);
|
||||
}
|
||||
|
Reference in New Issue
Block a user