From 1c3646f597009f2c7218cded888e7b6b0c5f3146 Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Sat, 5 Sep 1998 06:53:43 +0000 Subject: [PATCH] use g_mem_chunk_alloc0() to allocate the memchunk, so the correct size of Sat Sep 5 04:40:02 1998 Tim Janik * glib.h: (g_chunk_new0): use g_mem_chunk_alloc0() to allocate the memchunk, so the correct size of the memchunk is allocated with 0's and not a memory portion of the size of the desired type. * gmem.c: new function g_mem_chunk_alloc0() which will initialize a memory area allocated with g_mem_chunk_alloc() with 0's. --- ChangeLog | 12 +++++++++++- ChangeLog.pre-2-0 | 12 +++++++++++- ChangeLog.pre-2-10 | 12 +++++++++++- ChangeLog.pre-2-12 | 12 +++++++++++- ChangeLog.pre-2-2 | 12 +++++++++++- ChangeLog.pre-2-4 | 12 +++++++++++- ChangeLog.pre-2-6 | 12 +++++++++++- ChangeLog.pre-2-8 | 12 +++++++++++- glib.h | 3 ++- glib/glib.h | 3 ++- glib/gmem.c | 16 ++++++++++++++++ gmem.c | 16 ++++++++++++++++ 12 files changed, 124 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9cdfbfbaa..635d56772 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,16 @@ +Sat Sep 5 04:40:02 1998 Tim Janik + + * glib.h: + (g_chunk_new0): use g_mem_chunk_alloc0() to allocate the memchunk, + so the correct size of the memchunk is allocated with 0's and not + a memory portion of the size of the desired type. + + * gmem.c: new function g_mem_chunk_alloc0() which will initialize + a memory area allocated with g_mem_chunk_alloc() with 0's. + Wed Sep 2 19:13:28 1998 Owen Taylor - * garray.c glib.h (g_array_[ap/pr]epend_vals): make + * garray.c glib.h (g_array_[ap/pre]pend_vals): make data argument const. Wed Aug 26 06:32:40 1998 Tim Janik diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 9cdfbfbaa..635d56772 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,6 +1,16 @@ +Sat Sep 5 04:40:02 1998 Tim Janik + + * glib.h: + (g_chunk_new0): use g_mem_chunk_alloc0() to allocate the memchunk, + so the correct size of the memchunk is allocated with 0's and not + a memory portion of the size of the desired type. + + * gmem.c: new function g_mem_chunk_alloc0() which will initialize + a memory area allocated with g_mem_chunk_alloc() with 0's. + Wed Sep 2 19:13:28 1998 Owen Taylor - * garray.c glib.h (g_array_[ap/pr]epend_vals): make + * garray.c glib.h (g_array_[ap/pre]pend_vals): make data argument const. Wed Aug 26 06:32:40 1998 Tim Janik diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 9cdfbfbaa..635d56772 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,6 +1,16 @@ +Sat Sep 5 04:40:02 1998 Tim Janik + + * glib.h: + (g_chunk_new0): use g_mem_chunk_alloc0() to allocate the memchunk, + so the correct size of the memchunk is allocated with 0's and not + a memory portion of the size of the desired type. + + * gmem.c: new function g_mem_chunk_alloc0() which will initialize + a memory area allocated with g_mem_chunk_alloc() with 0's. + Wed Sep 2 19:13:28 1998 Owen Taylor - * garray.c glib.h (g_array_[ap/pr]epend_vals): make + * garray.c glib.h (g_array_[ap/pre]pend_vals): make data argument const. Wed Aug 26 06:32:40 1998 Tim Janik diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 9cdfbfbaa..635d56772 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,6 +1,16 @@ +Sat Sep 5 04:40:02 1998 Tim Janik + + * glib.h: + (g_chunk_new0): use g_mem_chunk_alloc0() to allocate the memchunk, + so the correct size of the memchunk is allocated with 0's and not + a memory portion of the size of the desired type. + + * gmem.c: new function g_mem_chunk_alloc0() which will initialize + a memory area allocated with g_mem_chunk_alloc() with 0's. + Wed Sep 2 19:13:28 1998 Owen Taylor - * garray.c glib.h (g_array_[ap/pr]epend_vals): make + * garray.c glib.h (g_array_[ap/pre]pend_vals): make data argument const. Wed Aug 26 06:32:40 1998 Tim Janik diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 9cdfbfbaa..635d56772 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,6 +1,16 @@ +Sat Sep 5 04:40:02 1998 Tim Janik + + * glib.h: + (g_chunk_new0): use g_mem_chunk_alloc0() to allocate the memchunk, + so the correct size of the memchunk is allocated with 0's and not + a memory portion of the size of the desired type. + + * gmem.c: new function g_mem_chunk_alloc0() which will initialize + a memory area allocated with g_mem_chunk_alloc() with 0's. + Wed Sep 2 19:13:28 1998 Owen Taylor - * garray.c glib.h (g_array_[ap/pr]epend_vals): make + * garray.c glib.h (g_array_[ap/pre]pend_vals): make data argument const. Wed Aug 26 06:32:40 1998 Tim Janik diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 9cdfbfbaa..635d56772 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,6 +1,16 @@ +Sat Sep 5 04:40:02 1998 Tim Janik + + * glib.h: + (g_chunk_new0): use g_mem_chunk_alloc0() to allocate the memchunk, + so the correct size of the memchunk is allocated with 0's and not + a memory portion of the size of the desired type. + + * gmem.c: new function g_mem_chunk_alloc0() which will initialize + a memory area allocated with g_mem_chunk_alloc() with 0's. + Wed Sep 2 19:13:28 1998 Owen Taylor - * garray.c glib.h (g_array_[ap/pr]epend_vals): make + * garray.c glib.h (g_array_[ap/pre]pend_vals): make data argument const. Wed Aug 26 06:32:40 1998 Tim Janik diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 9cdfbfbaa..635d56772 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,6 +1,16 @@ +Sat Sep 5 04:40:02 1998 Tim Janik + + * glib.h: + (g_chunk_new0): use g_mem_chunk_alloc0() to allocate the memchunk, + so the correct size of the memchunk is allocated with 0's and not + a memory portion of the size of the desired type. + + * gmem.c: new function g_mem_chunk_alloc0() which will initialize + a memory area allocated with g_mem_chunk_alloc() with 0's. + Wed Sep 2 19:13:28 1998 Owen Taylor - * garray.c glib.h (g_array_[ap/pr]epend_vals): make + * garray.c glib.h (g_array_[ap/pre]pend_vals): make data argument const. Wed Aug 26 06:32:40 1998 Tim Janik diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 9cdfbfbaa..635d56772 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,6 +1,16 @@ +Sat Sep 5 04:40:02 1998 Tim Janik + + * glib.h: + (g_chunk_new0): use g_mem_chunk_alloc0() to allocate the memchunk, + so the correct size of the memchunk is allocated with 0's and not + a memory portion of the size of the desired type. + + * gmem.c: new function g_mem_chunk_alloc0() which will initialize + a memory area allocated with g_mem_chunk_alloc() with 0's. + Wed Sep 2 19:13:28 1998 Owen Taylor - * garray.c glib.h (g_array_[ap/pr]epend_vals): make + * garray.c glib.h (g_array_[ap/pre]pend_vals): make data argument const. Wed Aug 26 06:32:40 1998 Tim Janik diff --git a/glib.h b/glib.h index a7c3df6ae..64c2943f6 100644 --- a/glib.h +++ b/glib.h @@ -273,7 +273,7 @@ (type *) g_mem_chunk_alloc (chunk) \ ) #define g_chunk_new0(type, chunk) ( \ - (type *) memset (g_mem_chunk_alloc (chunk), 0, sizeof (type)) \ + (type *) g_mem_chunk_alloc0 (chunk) \ ) #define g_chunk_free(mem, mem_chunk) G_STMT_START { \ g_mem_chunk_free ((mem_chunk), (mem)); \ @@ -1087,6 +1087,7 @@ GMemChunk* g_mem_chunk_new (gchar *name, gint type); void g_mem_chunk_destroy (GMemChunk *mem_chunk); gpointer g_mem_chunk_alloc (GMemChunk *mem_chunk); +gpointer g_mem_chunk_alloc0 (GMemChunk *mem_chunk); void g_mem_chunk_free (GMemChunk *mem_chunk, gpointer mem); void g_mem_chunk_clean (GMemChunk *mem_chunk); diff --git a/glib/glib.h b/glib/glib.h index a7c3df6ae..64c2943f6 100644 --- a/glib/glib.h +++ b/glib/glib.h @@ -273,7 +273,7 @@ (type *) g_mem_chunk_alloc (chunk) \ ) #define g_chunk_new0(type, chunk) ( \ - (type *) memset (g_mem_chunk_alloc (chunk), 0, sizeof (type)) \ + (type *) g_mem_chunk_alloc0 (chunk) \ ) #define g_chunk_free(mem, mem_chunk) G_STMT_START { \ g_mem_chunk_free ((mem_chunk), (mem)); \ @@ -1087,6 +1087,7 @@ GMemChunk* g_mem_chunk_new (gchar *name, gint type); void g_mem_chunk_destroy (GMemChunk *mem_chunk); gpointer g_mem_chunk_alloc (GMemChunk *mem_chunk); +gpointer g_mem_chunk_alloc0 (GMemChunk *mem_chunk); void g_mem_chunk_free (GMemChunk *mem_chunk, gpointer mem); void g_mem_chunk_clean (GMemChunk *mem_chunk); diff --git a/glib/gmem.c b/glib/gmem.c index c662ae710..70444a840 100644 --- a/glib/gmem.c +++ b/glib/gmem.c @@ -617,6 +617,22 @@ outa_here: return mem; } +gpointer +g_mem_chunk_alloc0 (GMemChunk *mem_chunk) +{ + gpointer mem; + + mem = g_mem_chunk_alloc (mem_chunk); + if (mem) + { + GRealMemChunk *rmem_chunk = (GRealMemChunk*) mem_chunk; + + memset (mem, 0, rmem_chunk->atom_size); + } + + return mem; +} + void g_mem_chunk_free (GMemChunk *mem_chunk, gpointer mem) diff --git a/gmem.c b/gmem.c index c662ae710..70444a840 100644 --- a/gmem.c +++ b/gmem.c @@ -617,6 +617,22 @@ outa_here: return mem; } +gpointer +g_mem_chunk_alloc0 (GMemChunk *mem_chunk) +{ + gpointer mem; + + mem = g_mem_chunk_alloc (mem_chunk); + if (mem) + { + GRealMemChunk *rmem_chunk = (GRealMemChunk*) mem_chunk; + + memset (mem, 0, rmem_chunk->atom_size); + } + + return mem; +} + void g_mem_chunk_free (GMemChunk *mem_chunk, gpointer mem)