summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2000-12-19 09:35:44 +0000
committerAlexander Larsson <alexl@src.gnome.org>2000-12-19 09:35:44 +0000
commitc7f80dbb13b58e439291d57f28e91accbc7bdefb (patch)
tree38876a36197545465a0178fd29974d6b7a1cc983
parent4f9e04c1d78ffe95f60101bea8381c6be5575069 (diff)
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.
-rw-r--r--ChangeLog11
-rw-r--r--ChangeLog.pre-2-011
-rw-r--r--ChangeLog.pre-2-1011
-rw-r--r--ChangeLog.pre-2-1211
-rw-r--r--ChangeLog.pre-2-211
-rw-r--r--ChangeLog.pre-2-411
-rw-r--r--ChangeLog.pre-2-611
-rw-r--r--ChangeLog.pre-2-811
-rw-r--r--configure.in11
-rw-r--r--glib/glist.c40
-rw-r--r--glib/gmem.c93
-rw-r--r--glib/gnode.c34
-rw-r--r--glib/gslist.c39
-rw-r--r--glist.c40
-rw-r--r--gmem.c93
-rw-r--r--gnode.c34
-rw-r--r--gslist.c39
17 files changed, 509 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 5906d1aba..abef08a0d 100644
--- a/ChangeLog
+++ b/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>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index 5906d1aba..abef08a0d 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -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>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 5906d1aba..abef08a0d 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -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>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12
index 5906d1aba..abef08a0d 100644
--- a/ChangeLog.pre-2-12
+++ b/ChangeLog.pre-2-12
@@ -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>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index 5906d1aba..abef08a0d 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -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>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 5906d1aba..abef08a0d 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -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>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 5906d1aba..abef08a0d 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -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>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 5906d1aba..abef08a0d 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -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>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
diff --git a/configure.in b/configure.in
index 4ec48f983..0eec822d3 100644
--- a/configure.in
+++ b/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_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]
@@ -142,6 +143,16 @@ else
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"
diff --git a/glib/glist.c b/glib/glist.c
index 4b5934432..9ca754a45 100644
--- a/glib/glist.c
+++ b/glib/glist.c
@@ -28,9 +28,14 @@
* MT safe
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "glib.h"
+#ifndef DISABLE_MEM_POOLS
struct _GAllocator /* from gmem.c */
{
gchar *name;
@@ -197,6 +202,41 @@ g_list_free_1 (GList *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*
g_list_append (GList *list,
gpointer data)
diff --git a/glib/gmem.c b/glib/gmem.c
index bc0f92385..73e01a993 100644
--- a/glib/gmem.c
+++ b/glib/gmem.c
@@ -124,6 +124,7 @@ struct _GRealMemChunk
};
+#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,
@@ -136,6 +137,7 @@ static gint g_mem_chunk_area_search (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;
@@ -460,6 +462,7 @@ g_mem_check (gpointer mem)
#endif /* ENABLE_MEM_CHECK */
}
+#ifndef DISABLE_MEM_POOLS
GMemChunk*
g_mem_chunk_new (gchar *name,
gint atom_size,
@@ -960,6 +963,92 @@ g_mem_chunk_area_search (GMemArea *a,
}
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
*/
@@ -1010,8 +1099,10 @@ g_allocator_free (GAllocator *allocator)
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
diff --git a/glib/gnode.c b/glib/gnode.c
index 5b72300c5..77143a8c4 100644
--- a/glib/gnode.c
+++ b/glib/gnode.c
@@ -31,8 +31,13 @@
* MT safe
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "glib.h"
+#ifndef DISABLE_MEM_POOLS
/* node allocation
*/
struct _GAllocator /* from gmem.c */
@@ -167,6 +172,35 @@ g_nodes_free (GNode *node)
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)
diff --git a/glib/gslist.c b/glib/gslist.c
index d8cc6996a..ebf883e23 100644
--- a/glib/gslist.c
+++ b/glib/gslist.c
@@ -28,9 +28,14 @@
* MT safe
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "glib.h"
+#ifndef DISABLE_MEM_POOLS
struct _GAllocator /* from gmem.c */
{
gchar *name;
@@ -189,6 +194,40 @@ g_slist_free_1 (GSList *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*
g_slist_append (GSList *list,
diff --git a/glist.c b/glist.c
index 4b5934432..9ca754a45 100644
--- a/glist.c
+++ b/glist.c
@@ -28,9 +28,14 @@
* MT safe
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "glib.h"
+#ifndef DISABLE_MEM_POOLS
struct _GAllocator /* from gmem.c */
{
gchar *name;
@@ -197,6 +202,41 @@ g_list_free_1 (GList *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*
g_list_append (GList *list,
gpointer data)
diff --git a/gmem.c b/gmem.c
index bc0f92385..73e01a993 100644
--- a/gmem.c
+++ b/gmem.c
@@ -124,6 +124,7 @@ struct _GRealMemChunk
};
+#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,
@@ -136,6 +137,7 @@ static gint g_mem_chunk_area_search (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;
@@ -460,6 +462,7 @@ g_mem_check (gpointer mem)
#endif /* ENABLE_MEM_CHECK */
}
+#ifndef DISABLE_MEM_POOLS
GMemChunk*
g_mem_chunk_new (gchar *name,
gint atom_size,
@@ -960,6 +963,92 @@ g_mem_chunk_area_search (GMemArea *a,
}
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
*/
@@ -1010,8 +1099,10 @@ g_allocator_free (GAllocator *allocator)
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
diff --git a/gnode.c b/gnode.c
index 5b72300c5..77143a8c4 100644
--- a/gnode.c
+++ b/gnode.c
@@ -31,8 +31,13 @@
* MT safe
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "glib.h"
+#ifndef DISABLE_MEM_POOLS
/* node allocation
*/
struct _GAllocator /* from gmem.c */
@@ -167,6 +172,35 @@ g_nodes_free (GNode *node)
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)
diff --git a/gslist.c b/gslist.c
index d8cc6996a..ebf883e23 100644
--- a/gslist.c
+++ b/gslist.c
@@ -28,9 +28,14 @@
* MT safe
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "glib.h"
+#ifndef DISABLE_MEM_POOLS
struct _GAllocator /* from gmem.c */
{
gchar *name;
@@ -189,6 +194,40 @@ g_slist_free_1 (GSList *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*
g_slist_append (GSList *list,