From: Sven Neumann Date: Wed, 13 Jun 2007 18:56:51 +0000 (+0000) Subject: glib/gslice.[ch] added g_slice_copy() and g_slice_dup() (#442029). X-Git-Tag: GLIB_2_13_5~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=57336cec3fa3d8894750b6767147eced975c32e1;p=platform%2Fupstream%2Fglib.git glib/gslice.[ch] added g_slice_copy() and g_slice_dup() (#442029). 2007-06-13 Sven Neumann * glib/gslice.[ch] added g_slice_copy() and g_slice_dup() (#442029). * glib/glib.symbols: updated. svn path=/trunk/; revision=5554 --- diff --git a/ChangeLog b/ChangeLog index 2049aa8..7120642 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-06-13 Sven Neumann + + * glib/gslice.[ch] added g_slice_copy() and g_slice_dup() (#442029). + + * glib/glib.symbols: updated. + 2007-06-12 Behdad Esfahbod * glib/gunicode.h: Add more G_GNUC_CONST and G_GNUC_PURE. diff --git a/glib/glib.symbols b/glib/glib.symbols index a924b6d..4489a23 100644 --- a/glib/glib.symbols +++ b/glib/glib.symbols @@ -684,6 +684,7 @@ g_blow_chunks #if IN_FILE(__G_SLICE_C__) g_slice_alloc G_GNUC_MALLOC g_slice_alloc0 G_GNUC_MALLOC +g_slice_copy G_GNUC_MALLOC g_slice_free1 g_slice_free_chain_with_offset g_slice_set_config diff --git a/glib/gslice.c b/glib/gslice.c index db08070..1c0fecd 100644 --- a/glib/gslice.c +++ b/glib/gslice.c @@ -815,6 +815,16 @@ g_slice_alloc0 (gsize mem_size) return mem; } +gpointer +g_slice_copy (gsize mem_size, + gpointer mem_block) +{ + gpointer mem = g_slice_alloc (mem_size); + if (mem) + memcpy (mem, mem_block, mem_size); + return mem; +} + void g_slice_free1 (gsize mem_size, gpointer mem_block) diff --git a/glib/gslice.h b/glib/gslice.h index 93b545a..84a6e89 100644 --- a/glib/gslice.h +++ b/glib/gslice.h @@ -31,6 +31,8 @@ G_BEGIN_DECLS */ gpointer g_slice_alloc (gsize block_size) G_GNUC_MALLOC; gpointer g_slice_alloc0 (gsize block_size) G_GNUC_MALLOC; +gpointer g_slice_copy (gsize block_size, + gpointer mem_block) G_GNUC_MALLOC; void g_slice_free1 (gsize block_size, gpointer mem_block); void g_slice_free_chain_with_offset (gsize block_size, @@ -38,7 +40,10 @@ void g_slice_free_chain_with_offset (gsize block_size, gsize next_offset); #define g_slice_new(type) ((type*) g_slice_alloc (sizeof (type))) #define g_slice_new0(type) ((type*) g_slice_alloc0 (sizeof (type))) -/* g_slice_free (MemoryBlockType, +/* MemoryBlockType * + * g_slice_dup (MemoryBlockType, + * MemoryBlockType *mem_block); + * g_slice_free (MemoryBlockType, * MemoryBlockType *mem_block); * g_slice_free_chain (MemoryBlockType, * MemoryBlockType *first_chain_block, @@ -48,6 +53,8 @@ void g_slice_free_chain_with_offset (gsize block_size, */ /* we go through extra hoops to ensure type safety */ +#define g_slice_dup(type, mem) \ + (1 ? g_slice_copy (sizeof (type), (mem)) : (type*) ((type*) 0 == (mem))) #define g_slice_free(type, mem) do { \ if (1) g_slice_free1 (sizeof (type), (mem)); \ else (void) ((type*) 0 == (mem)); \