Use g_slice if glib >=2.10
authoretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 24 Jul 2009 13:50:57 +0000 (13:50 +0000)
committeretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 24 Jul 2009 13:50:57 +0000 (13:50 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@29187 f5534014-38df-0310-8fa8-9805f1628bb7

cfile.h
file.c

diff --git a/cfile.h b/cfile.h
index 1d28d0749baa5ddb1f0efc683f72d542a4603522..122886b776485c7d01b93c219171e9033912b6e0 100644 (file)
--- a/cfile.h
+++ b/cfile.h
@@ -75,7 +75,14 @@ typedef struct _capture_file {
   /* packet data */
   union wtap_pseudo_header pseudo_header; /* Packet pseudo_header */
   guint8       pd[WTAP_MAX_PACKET_SIZE];  /* Packet data */
+  /* memory chunks have been deprecated in favor of the slice allocator, 
+   * which has been added in 2.10
+   */
+#if GLIB_CHECK_VERSION(2,10,0)
+
+#else
   GMemChunk   *plist_chunk;     /* Memory chunk for frame_data structures */
+#endif
   frame_data  *plist;           /* Packet list */
   frame_data  *plist_end;       /* Last packet in list */
   frame_data  *first_displayed; /* First frame displayed */
diff --git a/file.c b/file.c
index d4fa81986ff226c00b22bc27880a10e4c456aae9..fb205268461f4df562813665a0fe7967ebcb6153 100644 (file)
--- a/file.c
+++ b/file.c
@@ -277,12 +277,17 @@ cf_open(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
   nstime_set_unset(&first_ts);
   nstime_set_unset(&prev_dis_ts);
 
+#if GLIB_CHECK_VERSION(2,10,0)
+#else
+  /* memory chunks have been deprecated in favor of the slice allocator, 
+   * which has been added in 2.10
+   */
   cf->plist_chunk = g_mem_chunk_new("frame_data_chunk",
        sizeof(frame_data),
        FRAME_DATA_CHUNK_SIZE * sizeof(frame_data),
        G_ALLOC_AND_FREE);
   g_assert(cf->plist_chunk);
-
+#endif
   /* change the time formats now, as we might have a new precision */
   cf_change_time_formats(cf);
 
@@ -329,10 +334,16 @@ cf_reset_state(capture_file *cf)
   /* ...which means we have nothing to save. */
   cf->user_saved = FALSE;
 
+#if GLIB_CHECK_VERSION(2,10,0)
+#else
+  /* memory chunks have been deprecated in favor of the slice allocator, 
+   * which has been added in 2.10
+   */
   if (cf->plist_chunk != NULL) {
     g_mem_chunk_destroy(cf->plist_chunk);
     cf->plist_chunk = NULL;
   }
+#endif
   if (cf->rfcode != NULL) {
     dfilter_free(cf->rfcode);
     cf->rfcode = NULL;
@@ -1158,9 +1169,15 @@ read_packet(capture_file *cf, dfilter_t *dfcode,
   epan_dissect_t *edt;
   int row = -1;
 
-  /* Allocate the next list entry, and add it to the list. */
+  /* Allocate the next list entry, and add it to the list. 
+   * memory chunks have been deprecated in favor of the slice allocator, 
+   * which has been added in 2.10
+   */
+#if GLIB_CHECK_VERSION(2,10,0)
+  fdata = g_slice_new(frame_data);
+#else
   fdata = g_mem_chunk_alloc(cf->plist_chunk);
-
+#endif
   fdata->num = 0;
   fdata->next = NULL;
   fdata->prev = NULL;
@@ -1217,7 +1234,14 @@ read_packet(capture_file *cf, dfilter_t *dfcode,
        ...but, at least in one test I did, where I just made the chunk
        a G_ALLOC_ONLY chunk and read in a huge capture file, it didn't
        seem to save a noticeable amount of time or space. */
+#if GLIB_CHECK_VERSION(2,10,0)
+  /* memory chunks have been deprecated in favor of the slice allocator, 
+   * which has been added in 2.10
+   */
+       g_slice_free(frame_data,fdata);
+#else
     g_mem_chunk_free(cf->plist_chunk, fdata);
+#endif
   }
 
   return row;