+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>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
+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>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
+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>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
+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>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
+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>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
+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>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
+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>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
+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>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
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(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]],
, enable_ansi=no)
AC_ARG_ENABLE(threads, [ --enable-threads turn on basic thread support [default=yes]
AC_MSG_RESULT(no)
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
test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
GLIB_DEBUG_FLAGS="-DG_ENABLE_DEBUG"
* MT safe
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "glib.h"
+#ifndef DISABLE_MEM_POOLS
struct _GAllocator /* from gmem.c */
{
gchar *name;
_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*
g_list_append (GList *list,
gpointer data)
};
+#ifndef DISABLE_MEM_POOLS
static gulong g_mem_chunk_compute_size (gulong size,
gulong min_size) G_GNUC_CONST;
static gint g_mem_chunk_area_compare (GMemArea *a,
* g_malloc, the same holds true for StaticPrivate */
static GMutex* mem_chunks_lock = NULL;
static GRealMemChunk *mem_chunks = NULL;
+#endif
#ifdef ENABLE_MEM_PROFILE
static GMutex* mem_profile_lock;
#endif /* ENABLE_MEM_CHECK */
}
+#ifndef DISABLE_MEM_POOLS
GMemChunk*
g_mem_chunk_new (gchar *name,
gint atom_size,
}
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
*/
void
g_mem_init (void)
{
+#ifndef DISABLE_MEM_POOLS
mem_chunks_lock = g_mutex_new();
-#ifdef ENABLE_MEM_PROFILE
+#endif
+#if ENABLE_MEM_PROFILE
mem_profile_lock = g_mutex_new();
allocating_for_mem_chunk = g_private_new(NULL);
#endif
* MT safe
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "glib.h"
+#ifndef DISABLE_MEM_POOLS
/* node allocation
*/
struct _GAllocator /* from gmem.c */
current_allocator->free_nodes = node;
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
g_node_destroy (GNode *root)
* MT safe
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "glib.h"
+#ifndef DISABLE_MEM_POOLS
struct _GAllocator /* from gmem.c */
{
gchar *name;
{
_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*
g_slist_append (GSList *list,
* MT safe
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "glib.h"
+#ifndef DISABLE_MEM_POOLS
struct _GAllocator /* from gmem.c */
{
gchar *name;
_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*
g_list_append (GList *list,
gpointer data)
};
+#ifndef DISABLE_MEM_POOLS
static gulong g_mem_chunk_compute_size (gulong size,
gulong min_size) G_GNUC_CONST;
static gint g_mem_chunk_area_compare (GMemArea *a,
* g_malloc, the same holds true for StaticPrivate */
static GMutex* mem_chunks_lock = NULL;
static GRealMemChunk *mem_chunks = NULL;
+#endif
#ifdef ENABLE_MEM_PROFILE
static GMutex* mem_profile_lock;
#endif /* ENABLE_MEM_CHECK */
}
+#ifndef DISABLE_MEM_POOLS
GMemChunk*
g_mem_chunk_new (gchar *name,
gint atom_size,
}
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
*/
void
g_mem_init (void)
{
+#ifndef DISABLE_MEM_POOLS
mem_chunks_lock = g_mutex_new();
-#ifdef ENABLE_MEM_PROFILE
+#endif
+#if ENABLE_MEM_PROFILE
mem_profile_lock = g_mutex_new();
allocating_for_mem_chunk = g_private_new(NULL);
#endif
* MT safe
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "glib.h"
+#ifndef DISABLE_MEM_POOLS
/* node allocation
*/
struct _GAllocator /* from gmem.c */
current_allocator->free_nodes = node;
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
g_node_destroy (GNode *root)
* MT safe
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "glib.h"
+#ifndef DISABLE_MEM_POOLS
struct _GAllocator /* from gmem.c */
{
gchar *name;
{
_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*
g_slist_append (GSList *list,