diff options
author | krj <krj@f5534014-38df-0310-8fa8-9805f1628bb7> | 2009-08-15 13:24:59 +0000 |
---|---|---|
committer | krj <krj@f5534014-38df-0310-8fa8-9805f1628bb7> | 2009-08-15 13:24:59 +0000 |
commit | edb9e0aaf28d059503ff0a4f070901cc448718e3 (patch) | |
tree | 6ebc886770328a17e246f6a8dac930302bb7f0a8 /epan/tvbuff.c | |
parent | 9f640dc58ec36e5f3791ac8f2ea72ccdc59a803b (diff) |
Use the slice allocator if GLIB >= 2,10,0 as suggested by Anders Broman
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@29434 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r-- | epan/tvbuff.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c index de0756ab4e..4dff958a57 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -58,23 +58,32 @@ ensure_contiguous_no_exception(tvbuff_t *tvb, gint offset, gint length, static const guint8* ensure_contiguous(tvbuff_t *tvb, gint offset, gint length); +#if GLIB_CHECK_VERSION(2,10,0) +#else /* We dole out tvbuff's from this memchunk. */ static GMemChunk *tvbuff_mem_chunk = NULL; +#endif void tvbuff_init(void) { +#if GLIB_CHECK_VERSION(2,10,0) +#else if (!tvbuff_mem_chunk) tvbuff_mem_chunk = g_mem_chunk_create(tvbuff_t, 20, G_ALLOC_AND_FREE); +#endif } void tvbuff_cleanup(void) { +#if GLIB_CHECK_VERSION(2,10,0) +#else if (tvbuff_mem_chunk) g_mem_chunk_destroy(tvbuff_mem_chunk); tvbuff_mem_chunk = NULL; +#endif } static void @@ -125,7 +134,11 @@ tvb_new(tvbuff_type type) { tvbuff_t *tvb; +#if GLIB_CHECK_VERSION(2,10,0) + tvb = g_slice_new(tvbuff_t); +#else tvb = g_chunk_new(tvbuff_t, tvbuff_mem_chunk); +#endif tvb_init(tvb, type); @@ -185,7 +198,11 @@ tvb_free(tvbuff_t* tvb) g_slist_free(tvb->used_in); } +#if GLIB_CHECK_VERSION(2,10,0) + g_slice_free(tvbuff_t, tvb); +#else g_chunk_free(tvb, tvbuff_mem_chunk); +#endif } } |