mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-09 20:35:49 +01:00
Added --disable-mem-pools option.
2000-12-19 Alexander Larsson <alexl@redhat.com> * configure.in: Added --disable-mem-pools option. * glist.c: * gslist.c: * gnode.c: * gmem.c: Disable free list and memory chunks if DISABLE_MEM_POOLS is defined.
This commit is contained in:
parent
4f9e04c1d7
commit
c7f80dbb13
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
2000-12-19 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
|
* configure.in:
|
||||||
|
Added --disable-mem-pools option.
|
||||||
|
|
||||||
|
* glist.c:
|
||||||
|
* gslist.c:
|
||||||
|
* gnode.c:
|
||||||
|
* gmem.c:
|
||||||
|
Disable free list and memory chunks if DISABLE_MEM_POOLS is defined.
|
||||||
|
|
||||||
2000-12-17 Tor Lillqvist <tml@iki.fi>
|
2000-12-17 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
|
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2000-12-19 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
|
* configure.in:
|
||||||
|
Added --disable-mem-pools option.
|
||||||
|
|
||||||
|
* glist.c:
|
||||||
|
* gslist.c:
|
||||||
|
* gnode.c:
|
||||||
|
* gmem.c:
|
||||||
|
Disable free list and memory chunks if DISABLE_MEM_POOLS is defined.
|
||||||
|
|
||||||
2000-12-17 Tor Lillqvist <tml@iki.fi>
|
2000-12-17 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
|
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2000-12-19 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
|
* configure.in:
|
||||||
|
Added --disable-mem-pools option.
|
||||||
|
|
||||||
|
* glist.c:
|
||||||
|
* gslist.c:
|
||||||
|
* gnode.c:
|
||||||
|
* gmem.c:
|
||||||
|
Disable free list and memory chunks if DISABLE_MEM_POOLS is defined.
|
||||||
|
|
||||||
2000-12-17 Tor Lillqvist <tml@iki.fi>
|
2000-12-17 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
|
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2000-12-19 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
|
* configure.in:
|
||||||
|
Added --disable-mem-pools option.
|
||||||
|
|
||||||
|
* glist.c:
|
||||||
|
* gslist.c:
|
||||||
|
* gnode.c:
|
||||||
|
* gmem.c:
|
||||||
|
Disable free list and memory chunks if DISABLE_MEM_POOLS is defined.
|
||||||
|
|
||||||
2000-12-17 Tor Lillqvist <tml@iki.fi>
|
2000-12-17 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
|
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2000-12-19 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
|
* configure.in:
|
||||||
|
Added --disable-mem-pools option.
|
||||||
|
|
||||||
|
* glist.c:
|
||||||
|
* gslist.c:
|
||||||
|
* gnode.c:
|
||||||
|
* gmem.c:
|
||||||
|
Disable free list and memory chunks if DISABLE_MEM_POOLS is defined.
|
||||||
|
|
||||||
2000-12-17 Tor Lillqvist <tml@iki.fi>
|
2000-12-17 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
|
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2000-12-19 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
|
* configure.in:
|
||||||
|
Added --disable-mem-pools option.
|
||||||
|
|
||||||
|
* glist.c:
|
||||||
|
* gslist.c:
|
||||||
|
* gnode.c:
|
||||||
|
* gmem.c:
|
||||||
|
Disable free list and memory chunks if DISABLE_MEM_POOLS is defined.
|
||||||
|
|
||||||
2000-12-17 Tor Lillqvist <tml@iki.fi>
|
2000-12-17 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
|
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2000-12-19 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
|
* configure.in:
|
||||||
|
Added --disable-mem-pools option.
|
||||||
|
|
||||||
|
* glist.c:
|
||||||
|
* gslist.c:
|
||||||
|
* gnode.c:
|
||||||
|
* gmem.c:
|
||||||
|
Disable free list and memory chunks if DISABLE_MEM_POOLS is defined.
|
||||||
|
|
||||||
2000-12-17 Tor Lillqvist <tml@iki.fi>
|
2000-12-17 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
|
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2000-12-19 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
|
* configure.in:
|
||||||
|
Added --disable-mem-pools option.
|
||||||
|
|
||||||
|
* glist.c:
|
||||||
|
* gslist.c:
|
||||||
|
* gnode.c:
|
||||||
|
* gmem.c:
|
||||||
|
Disable free list and memory chunks if DISABLE_MEM_POOLS is defined.
|
||||||
|
|
||||||
2000-12-17 Tor Lillqvist <tml@iki.fi>
|
2000-12-17 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
|
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
|
||||||
|
11
configure.in
11
configure.in
@ -105,6 +105,7 @@ AC_ARG_ENABLE(msg-prefix, [ --enable-msg-prefix turn on program name and PI
|
|||||||
AC_ARG_ENABLE(mem_check, [ --enable-mem-check turn on malloc/free sanity checking [default=no]],,enable_mem_check=no)
|
AC_ARG_ENABLE(mem_check, [ --enable-mem-check turn on malloc/free sanity checking [default=no]],,enable_mem_check=no)
|
||||||
AC_ARG_ENABLE(mem_profile, [ --enable-mem-profile turn on malloc profiling atexit [default=no]],,enable_mem_profile=no)
|
AC_ARG_ENABLE(mem_profile, [ --enable-mem-profile turn on malloc profiling atexit [default=no]],,enable_mem_profile=no)
|
||||||
AC_ARG_ENABLE(gc_friendly, [ --enable-gc-friendly turn on garbage collector friendliness [default=no]],,enable_gc_friendly=no)
|
AC_ARG_ENABLE(gc_friendly, [ --enable-gc-friendly turn on garbage collector friendliness [default=no]],,enable_gc_friendly=no)
|
||||||
|
AC_ARG_ENABLE(mem_pools, [ --disable-mem-pools disable all glib memory pools],,disable_mem_pools=no)
|
||||||
AC_ARG_ENABLE(ansi, [ --enable-ansi turn on strict ansi [default=no]],
|
AC_ARG_ENABLE(ansi, [ --enable-ansi turn on strict ansi [default=no]],
|
||||||
, enable_ansi=no)
|
, enable_ansi=no)
|
||||||
AC_ARG_ENABLE(threads, [ --enable-threads turn on basic thread support [default=yes]
|
AC_ARG_ENABLE(threads, [ --enable-threads turn on basic thread support [default=yes]
|
||||||
@ -142,6 +143,16 @@ else
|
|||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
AC_MSG_CHECKING(whether to disable memory pools)
|
||||||
|
if test "x$disable_mem_pools" = "xno"; then
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
else
|
||||||
|
AC_DEFINE(DISABLE_MEM_POOLS, 1, [Whether to disable memory pools])
|
||||||
|
AC_SUBST(DISABLE_MEM_POOLS)
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
if test "x$enable_debug" = "xyes"; then
|
if test "x$enable_debug" = "xyes"; then
|
||||||
test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
|
test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
|
||||||
GLIB_DEBUG_FLAGS="-DG_ENABLE_DEBUG"
|
GLIB_DEBUG_FLAGS="-DG_ENABLE_DEBUG"
|
||||||
|
40
glib/glist.c
40
glib/glist.c
@ -28,9 +28,14 @@
|
|||||||
* MT safe
|
* MT safe
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "glib.h"
|
#include "glib.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef DISABLE_MEM_POOLS
|
||||||
struct _GAllocator /* from gmem.c */
|
struct _GAllocator /* from gmem.c */
|
||||||
{
|
{
|
||||||
gchar *name;
|
gchar *name;
|
||||||
@ -197,6 +202,41 @@ g_list_free_1 (GList *list)
|
|||||||
_g_list_free_1 (list);
|
_g_list_free_1 (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else /* DISABLE_MEM_POOLS */
|
||||||
|
|
||||||
|
#define _g_list_alloc g_list_alloc
|
||||||
|
GList*
|
||||||
|
g_list_alloc (void)
|
||||||
|
{
|
||||||
|
GList *list;
|
||||||
|
|
||||||
|
list = g_new0 (GList, 1);
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
g_list_free (GList *list)
|
||||||
|
{
|
||||||
|
GList *last;
|
||||||
|
|
||||||
|
while (list)
|
||||||
|
{
|
||||||
|
last = list;
|
||||||
|
list = list->next;
|
||||||
|
g_free (last);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define _g_list_free_1 g_list_free_1
|
||||||
|
void
|
||||||
|
g_list_free_1 (GList *list)
|
||||||
|
{
|
||||||
|
g_free (list);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
GList*
|
GList*
|
||||||
g_list_append (GList *list,
|
g_list_append (GList *list,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
|
93
glib/gmem.c
93
glib/gmem.c
@ -124,6 +124,7 @@ struct _GRealMemChunk
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef DISABLE_MEM_POOLS
|
||||||
static gulong g_mem_chunk_compute_size (gulong size,
|
static gulong g_mem_chunk_compute_size (gulong size,
|
||||||
gulong min_size) G_GNUC_CONST;
|
gulong min_size) G_GNUC_CONST;
|
||||||
static gint g_mem_chunk_area_compare (GMemArea *a,
|
static gint g_mem_chunk_area_compare (GMemArea *a,
|
||||||
@ -136,6 +137,7 @@ static gint g_mem_chunk_area_search (GMemArea *a,
|
|||||||
* g_malloc, the same holds true for StaticPrivate */
|
* g_malloc, the same holds true for StaticPrivate */
|
||||||
static GMutex* mem_chunks_lock = NULL;
|
static GMutex* mem_chunks_lock = NULL;
|
||||||
static GRealMemChunk *mem_chunks = NULL;
|
static GRealMemChunk *mem_chunks = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_MEM_PROFILE
|
#ifdef ENABLE_MEM_PROFILE
|
||||||
static GMutex* mem_profile_lock;
|
static GMutex* mem_profile_lock;
|
||||||
@ -460,6 +462,7 @@ g_mem_check (gpointer mem)
|
|||||||
#endif /* ENABLE_MEM_CHECK */
|
#endif /* ENABLE_MEM_CHECK */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef DISABLE_MEM_POOLS
|
||||||
GMemChunk*
|
GMemChunk*
|
||||||
g_mem_chunk_new (gchar *name,
|
g_mem_chunk_new (gchar *name,
|
||||||
gint atom_size,
|
gint atom_size,
|
||||||
@ -960,6 +963,92 @@ g_mem_chunk_area_search (GMemArea *a,
|
|||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#else /* DISABLE_MEM_POOLS */
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
guint alloc_size; /* the size of an atom */
|
||||||
|
} GMinimalMemChunk;
|
||||||
|
|
||||||
|
GMemChunk*
|
||||||
|
g_mem_chunk_new (gchar *name,
|
||||||
|
gint atom_size,
|
||||||
|
gulong area_size,
|
||||||
|
gint type)
|
||||||
|
{
|
||||||
|
GMinimalMemChunk *mem_chunk;
|
||||||
|
|
||||||
|
g_return_val_if_fail (atom_size > 0, NULL);
|
||||||
|
|
||||||
|
mem_chunk = g_new (GMinimalMemChunk, 1);
|
||||||
|
mem_chunk->alloc_size = atom_size;
|
||||||
|
|
||||||
|
return ((GMemChunk*) mem_chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
g_mem_chunk_destroy (GMemChunk *mem_chunk)
|
||||||
|
{
|
||||||
|
g_return_if_fail (mem_chunk != NULL);
|
||||||
|
|
||||||
|
g_free (mem_chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
gpointer
|
||||||
|
g_mem_chunk_alloc (GMemChunk *mem_chunk)
|
||||||
|
{
|
||||||
|
GMinimalMemChunk *minimal = (GMinimalMemChunk *)mem_chunk;
|
||||||
|
|
||||||
|
g_return_val_if_fail (mem_chunk != NULL, NULL);
|
||||||
|
|
||||||
|
return g_malloc (minimal->alloc_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
gpointer
|
||||||
|
g_mem_chunk_alloc0 (GMemChunk *mem_chunk)
|
||||||
|
{
|
||||||
|
GMinimalMemChunk *minimal = (GMinimalMemChunk *)mem_chunk;
|
||||||
|
|
||||||
|
g_return_val_if_fail (mem_chunk != NULL, NULL);
|
||||||
|
|
||||||
|
return g_malloc0 (minimal->alloc_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
g_mem_chunk_free (GMemChunk *mem_chunk,
|
||||||
|
gpointer mem)
|
||||||
|
{
|
||||||
|
g_return_if_fail (mem_chunk != NULL);
|
||||||
|
|
||||||
|
g_free (mem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
g_mem_chunk_clean (GMemChunk *mem_chunk)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
g_mem_chunk_reset (GMemChunk *mem_chunk)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
g_mem_chunk_print (GMemChunk *mem_chunk)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
g_mem_chunk_info (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
g_blow_chunks (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* DISABLE_MEM_POOLS */
|
||||||
|
|
||||||
/* generic allocators
|
/* generic allocators
|
||||||
*/
|
*/
|
||||||
@ -1010,8 +1099,10 @@ g_allocator_free (GAllocator *allocator)
|
|||||||
void
|
void
|
||||||
g_mem_init (void)
|
g_mem_init (void)
|
||||||
{
|
{
|
||||||
|
#ifndef DISABLE_MEM_POOLS
|
||||||
mem_chunks_lock = g_mutex_new();
|
mem_chunks_lock = g_mutex_new();
|
||||||
#ifdef ENABLE_MEM_PROFILE
|
#endif
|
||||||
|
#if ENABLE_MEM_PROFILE
|
||||||
mem_profile_lock = g_mutex_new();
|
mem_profile_lock = g_mutex_new();
|
||||||
allocating_for_mem_chunk = g_private_new(NULL);
|
allocating_for_mem_chunk = g_private_new(NULL);
|
||||||
#endif
|
#endif
|
||||||
|
34
glib/gnode.c
34
glib/gnode.c
@ -31,8 +31,13 @@
|
|||||||
* MT safe
|
* MT safe
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "glib.h"
|
#include "glib.h"
|
||||||
|
|
||||||
|
#ifndef DISABLE_MEM_POOLS
|
||||||
/* node allocation
|
/* node allocation
|
||||||
*/
|
*/
|
||||||
struct _GAllocator /* from gmem.c */
|
struct _GAllocator /* from gmem.c */
|
||||||
@ -167,6 +172,35 @@ g_nodes_free (GNode *node)
|
|||||||
current_allocator->free_nodes = node;
|
current_allocator->free_nodes = node;
|
||||||
G_UNLOCK (current_allocator);
|
G_UNLOCK (current_allocator);
|
||||||
}
|
}
|
||||||
|
#else /* DISABLE_MEM_POOLS */
|
||||||
|
|
||||||
|
GNode*
|
||||||
|
g_node_new (gpointer data)
|
||||||
|
{
|
||||||
|
GNode *node;
|
||||||
|
|
||||||
|
node = g_new0 (GNode, 1);
|
||||||
|
|
||||||
|
node->data = data;
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_nodes_free (GNode *root)
|
||||||
|
{
|
||||||
|
GNode *node, *next;
|
||||||
|
|
||||||
|
node = root;
|
||||||
|
while (node != NULL)
|
||||||
|
{
|
||||||
|
next = node->next;
|
||||||
|
g_nodes_free (node->children);
|
||||||
|
g_free (node);
|
||||||
|
node = next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
g_node_destroy (GNode *root)
|
g_node_destroy (GNode *root)
|
||||||
|
@ -28,9 +28,14 @@
|
|||||||
* MT safe
|
* MT safe
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "glib.h"
|
#include "glib.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef DISABLE_MEM_POOLS
|
||||||
struct _GAllocator /* from gmem.c */
|
struct _GAllocator /* from gmem.c */
|
||||||
{
|
{
|
||||||
gchar *name;
|
gchar *name;
|
||||||
@ -189,6 +194,40 @@ g_slist_free_1 (GSList *list)
|
|||||||
{
|
{
|
||||||
_g_slist_free_1 (list);
|
_g_slist_free_1 (list);
|
||||||
}
|
}
|
||||||
|
#else /* DISABLE_MEM_POOLS */
|
||||||
|
|
||||||
|
#define _g_slist_alloc g_slist_alloc
|
||||||
|
GSList*
|
||||||
|
g_slist_alloc (void)
|
||||||
|
{
|
||||||
|
GSList *list;
|
||||||
|
|
||||||
|
list = g_new0 (GSList, 1);
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
g_slist_free (GSList *list)
|
||||||
|
{
|
||||||
|
GSList *last;
|
||||||
|
|
||||||
|
while (list)
|
||||||
|
{
|
||||||
|
last = list;
|
||||||
|
list = list->next;
|
||||||
|
g_free (last);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define _g_slist_free_1 g_slist_free_1
|
||||||
|
void
|
||||||
|
g_slist_free_1 (GSList *list)
|
||||||
|
{
|
||||||
|
g_free (list);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
GSList*
|
GSList*
|
||||||
g_slist_append (GSList *list,
|
g_slist_append (GSList *list,
|
||||||
|
40
glist.c
40
glist.c
@ -28,9 +28,14 @@
|
|||||||
* MT safe
|
* MT safe
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "glib.h"
|
#include "glib.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef DISABLE_MEM_POOLS
|
||||||
struct _GAllocator /* from gmem.c */
|
struct _GAllocator /* from gmem.c */
|
||||||
{
|
{
|
||||||
gchar *name;
|
gchar *name;
|
||||||
@ -197,6 +202,41 @@ g_list_free_1 (GList *list)
|
|||||||
_g_list_free_1 (list);
|
_g_list_free_1 (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else /* DISABLE_MEM_POOLS */
|
||||||
|
|
||||||
|
#define _g_list_alloc g_list_alloc
|
||||||
|
GList*
|
||||||
|
g_list_alloc (void)
|
||||||
|
{
|
||||||
|
GList *list;
|
||||||
|
|
||||||
|
list = g_new0 (GList, 1);
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
g_list_free (GList *list)
|
||||||
|
{
|
||||||
|
GList *last;
|
||||||
|
|
||||||
|
while (list)
|
||||||
|
{
|
||||||
|
last = list;
|
||||||
|
list = list->next;
|
||||||
|
g_free (last);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define _g_list_free_1 g_list_free_1
|
||||||
|
void
|
||||||
|
g_list_free_1 (GList *list)
|
||||||
|
{
|
||||||
|
g_free (list);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
GList*
|
GList*
|
||||||
g_list_append (GList *list,
|
g_list_append (GList *list,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
|
93
gmem.c
93
gmem.c
@ -124,6 +124,7 @@ struct _GRealMemChunk
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef DISABLE_MEM_POOLS
|
||||||
static gulong g_mem_chunk_compute_size (gulong size,
|
static gulong g_mem_chunk_compute_size (gulong size,
|
||||||
gulong min_size) G_GNUC_CONST;
|
gulong min_size) G_GNUC_CONST;
|
||||||
static gint g_mem_chunk_area_compare (GMemArea *a,
|
static gint g_mem_chunk_area_compare (GMemArea *a,
|
||||||
@ -136,6 +137,7 @@ static gint g_mem_chunk_area_search (GMemArea *a,
|
|||||||
* g_malloc, the same holds true for StaticPrivate */
|
* g_malloc, the same holds true for StaticPrivate */
|
||||||
static GMutex* mem_chunks_lock = NULL;
|
static GMutex* mem_chunks_lock = NULL;
|
||||||
static GRealMemChunk *mem_chunks = NULL;
|
static GRealMemChunk *mem_chunks = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_MEM_PROFILE
|
#ifdef ENABLE_MEM_PROFILE
|
||||||
static GMutex* mem_profile_lock;
|
static GMutex* mem_profile_lock;
|
||||||
@ -460,6 +462,7 @@ g_mem_check (gpointer mem)
|
|||||||
#endif /* ENABLE_MEM_CHECK */
|
#endif /* ENABLE_MEM_CHECK */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef DISABLE_MEM_POOLS
|
||||||
GMemChunk*
|
GMemChunk*
|
||||||
g_mem_chunk_new (gchar *name,
|
g_mem_chunk_new (gchar *name,
|
||||||
gint atom_size,
|
gint atom_size,
|
||||||
@ -960,6 +963,92 @@ g_mem_chunk_area_search (GMemArea *a,
|
|||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#else /* DISABLE_MEM_POOLS */
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
guint alloc_size; /* the size of an atom */
|
||||||
|
} GMinimalMemChunk;
|
||||||
|
|
||||||
|
GMemChunk*
|
||||||
|
g_mem_chunk_new (gchar *name,
|
||||||
|
gint atom_size,
|
||||||
|
gulong area_size,
|
||||||
|
gint type)
|
||||||
|
{
|
||||||
|
GMinimalMemChunk *mem_chunk;
|
||||||
|
|
||||||
|
g_return_val_if_fail (atom_size > 0, NULL);
|
||||||
|
|
||||||
|
mem_chunk = g_new (GMinimalMemChunk, 1);
|
||||||
|
mem_chunk->alloc_size = atom_size;
|
||||||
|
|
||||||
|
return ((GMemChunk*) mem_chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
g_mem_chunk_destroy (GMemChunk *mem_chunk)
|
||||||
|
{
|
||||||
|
g_return_if_fail (mem_chunk != NULL);
|
||||||
|
|
||||||
|
g_free (mem_chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
gpointer
|
||||||
|
g_mem_chunk_alloc (GMemChunk *mem_chunk)
|
||||||
|
{
|
||||||
|
GMinimalMemChunk *minimal = (GMinimalMemChunk *)mem_chunk;
|
||||||
|
|
||||||
|
g_return_val_if_fail (mem_chunk != NULL, NULL);
|
||||||
|
|
||||||
|
return g_malloc (minimal->alloc_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
gpointer
|
||||||
|
g_mem_chunk_alloc0 (GMemChunk *mem_chunk)
|
||||||
|
{
|
||||||
|
GMinimalMemChunk *minimal = (GMinimalMemChunk *)mem_chunk;
|
||||||
|
|
||||||
|
g_return_val_if_fail (mem_chunk != NULL, NULL);
|
||||||
|
|
||||||
|
return g_malloc0 (minimal->alloc_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
g_mem_chunk_free (GMemChunk *mem_chunk,
|
||||||
|
gpointer mem)
|
||||||
|
{
|
||||||
|
g_return_if_fail (mem_chunk != NULL);
|
||||||
|
|
||||||
|
g_free (mem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
g_mem_chunk_clean (GMemChunk *mem_chunk)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
g_mem_chunk_reset (GMemChunk *mem_chunk)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
g_mem_chunk_print (GMemChunk *mem_chunk)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
g_mem_chunk_info (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
g_blow_chunks (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* DISABLE_MEM_POOLS */
|
||||||
|
|
||||||
/* generic allocators
|
/* generic allocators
|
||||||
*/
|
*/
|
||||||
@ -1010,8 +1099,10 @@ g_allocator_free (GAllocator *allocator)
|
|||||||
void
|
void
|
||||||
g_mem_init (void)
|
g_mem_init (void)
|
||||||
{
|
{
|
||||||
|
#ifndef DISABLE_MEM_POOLS
|
||||||
mem_chunks_lock = g_mutex_new();
|
mem_chunks_lock = g_mutex_new();
|
||||||
#ifdef ENABLE_MEM_PROFILE
|
#endif
|
||||||
|
#if ENABLE_MEM_PROFILE
|
||||||
mem_profile_lock = g_mutex_new();
|
mem_profile_lock = g_mutex_new();
|
||||||
allocating_for_mem_chunk = g_private_new(NULL);
|
allocating_for_mem_chunk = g_private_new(NULL);
|
||||||
#endif
|
#endif
|
||||||
|
34
gnode.c
34
gnode.c
@ -31,8 +31,13 @@
|
|||||||
* MT safe
|
* MT safe
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "glib.h"
|
#include "glib.h"
|
||||||
|
|
||||||
|
#ifndef DISABLE_MEM_POOLS
|
||||||
/* node allocation
|
/* node allocation
|
||||||
*/
|
*/
|
||||||
struct _GAllocator /* from gmem.c */
|
struct _GAllocator /* from gmem.c */
|
||||||
@ -167,6 +172,35 @@ g_nodes_free (GNode *node)
|
|||||||
current_allocator->free_nodes = node;
|
current_allocator->free_nodes = node;
|
||||||
G_UNLOCK (current_allocator);
|
G_UNLOCK (current_allocator);
|
||||||
}
|
}
|
||||||
|
#else /* DISABLE_MEM_POOLS */
|
||||||
|
|
||||||
|
GNode*
|
||||||
|
g_node_new (gpointer data)
|
||||||
|
{
|
||||||
|
GNode *node;
|
||||||
|
|
||||||
|
node = g_new0 (GNode, 1);
|
||||||
|
|
||||||
|
node->data = data;
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_nodes_free (GNode *root)
|
||||||
|
{
|
||||||
|
GNode *node, *next;
|
||||||
|
|
||||||
|
node = root;
|
||||||
|
while (node != NULL)
|
||||||
|
{
|
||||||
|
next = node->next;
|
||||||
|
g_nodes_free (node->children);
|
||||||
|
g_free (node);
|
||||||
|
node = next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
g_node_destroy (GNode *root)
|
g_node_destroy (GNode *root)
|
||||||
|
39
gslist.c
39
gslist.c
@ -28,9 +28,14 @@
|
|||||||
* MT safe
|
* MT safe
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "glib.h"
|
#include "glib.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef DISABLE_MEM_POOLS
|
||||||
struct _GAllocator /* from gmem.c */
|
struct _GAllocator /* from gmem.c */
|
||||||
{
|
{
|
||||||
gchar *name;
|
gchar *name;
|
||||||
@ -189,6 +194,40 @@ g_slist_free_1 (GSList *list)
|
|||||||
{
|
{
|
||||||
_g_slist_free_1 (list);
|
_g_slist_free_1 (list);
|
||||||
}
|
}
|
||||||
|
#else /* DISABLE_MEM_POOLS */
|
||||||
|
|
||||||
|
#define _g_slist_alloc g_slist_alloc
|
||||||
|
GSList*
|
||||||
|
g_slist_alloc (void)
|
||||||
|
{
|
||||||
|
GSList *list;
|
||||||
|
|
||||||
|
list = g_new0 (GSList, 1);
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
g_slist_free (GSList *list)
|
||||||
|
{
|
||||||
|
GSList *last;
|
||||||
|
|
||||||
|
while (list)
|
||||||
|
{
|
||||||
|
last = list;
|
||||||
|
list = list->next;
|
||||||
|
g_free (last);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define _g_slist_free_1 g_slist_free_1
|
||||||
|
void
|
||||||
|
g_slist_free_1 (GSList *list)
|
||||||
|
{
|
||||||
|
g_free (list);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
GSList*
|
GSList*
|
||||||
g_slist_append (GSList *list,
|
g_slist_append (GSList *list,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user