diff options
author | Gerald Combs <gerald@wireshark.org> | 2011-07-11 20:32:19 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2011-07-11 20:32:19 +0000 |
commit | 49b92440deaabb43114479e5b0e6af2c481ca8ac (patch) | |
tree | 011c39768a3be7d7d1f63d9d48d1b6e96383fdf0 /epan | |
parent | 1f923105f8a5c2c7bf82f1187984600ba14ef993 (diff) |
More GLIB_CHECK_VERSION cleanups. Update the minimum GLib/GTK+ versions
in README.devloper. Remove g_gnuc.h since it's no longer needed. Remove
tvbuff_init(), tvbuff_cleanup(), reassemble_init(), and
reassemble_cleanup() since they were only used for older GLib versions
which didn't support GSlices. Assume we always support the "matches"
operator.
svn path=/trunk/; revision=37978
Diffstat (limited to 'epan')
-rw-r--r-- | epan/Makefile.common | 1 | ||||
-rw-r--r-- | epan/dfilter/semcheck.c | 8 | ||||
-rw-r--r-- | epan/dissectors/packet-http.c | 8 | ||||
-rw-r--r-- | epan/dissectors/packet-isakmp.c | 33 | ||||
-rw-r--r-- | epan/dissectors/packet-synphasor.c | 22 | ||||
-rw-r--r-- | epan/emem.h | 2 | ||||
-rw-r--r-- | epan/epan.c | 2 | ||||
-rw-r--r-- | epan/except.h | 1 | ||||
-rw-r--r-- | epan/filesystem.c | 15 | ||||
-rw-r--r-- | epan/ftypes/ftype-bytes.c | 10 | ||||
-rw-r--r-- | epan/ftypes/ftype-pcre.c | 52 | ||||
-rw-r--r-- | epan/ftypes/ftype-string.c | 10 | ||||
-rw-r--r-- | epan/ftypes/ftype-tvbuff.c | 18 | ||||
-rw-r--r-- | epan/ftypes/ftypes-int.h | 2 | ||||
-rw-r--r-- | epan/ftypes/ftypes.h | 4 | ||||
-rw-r--r-- | epan/g_gnuc.h | 45 | ||||
-rw-r--r-- | epan/packet.c | 12 | ||||
-rw-r--r-- | epan/proto.h | 1 | ||||
-rw-r--r-- | epan/reassemble.c | 113 | ||||
-rw-r--r-- | epan/reassemble.h | 11 | ||||
-rw-r--r-- | epan/reassemble_test.c | 2 | ||||
-rw-r--r-- | epan/tvbtest.c | 6 | ||||
-rw-r--r-- | epan/tvbuff.c | 36 | ||||
-rw-r--r-- | epan/tvbuff.h | 10 |
24 files changed, 26 insertions, 398 deletions
diff --git a/epan/Makefile.common b/epan/Makefile.common index c625e5d86d..63c35ad076 100644 --- a/epan/Makefile.common +++ b/epan/Makefile.common @@ -178,7 +178,6 @@ LIBWIRESHARK_INCLUDES = \ gcp.h \ geoip_db.h \ golay.h \ - g_gnuc.h \ greproto.h \ guid-utils.h \ h225-persistentdata.h \ diff --git a/epan/dfilter/semcheck.c b/epan/dfilter/semcheck.c index 8f8cc28f59..194f328e34 100644 --- a/epan/dfilter/semcheck.c +++ b/epan/dfilter/semcheck.c @@ -1184,13 +1184,7 @@ check_test(stnode_t *st_node) check_relation("contains", TRUE, ftype_can_contains, st_node, st_arg1, st_arg2); break; case TEST_OP_MATCHES: -#if defined(HAVE_LIBPCRE) || GLIB_CHECK_VERSION(2,14,0) - check_relation("matches", TRUE, ftype_can_matches, st_node, st_arg1, st_arg2); -#else - dfilter_fail("This Wireshark version does not support the \"matches\" operation."); - THROW(TypeError); -#endif - break; + check_relation("matches", TRUE, ftype_can_matches, st_node, st_arg1, st_arg2); break; default: g_assert_not_reached(); diff --git a/epan/dissectors/packet-http.c b/epan/dissectors/packet-http.c index 94496165e2..04db9c84b3 100644 --- a/epan/dissectors/packet-http.c +++ b/epan/dissectors/packet-http.c @@ -2128,15 +2128,7 @@ process_header(tvbuff_t *tvb, int offset, int next_offset, case HDR_CONTENT_LENGTH: errno = 0; -#if GLIB_CHECK_VERSION(2,12,0) eh_ptr->content_length = g_ascii_strtoll(value, &p, 10); -#elif defined(HAVE_STRTOLL) - eh_ptr->content_length = strtoll(value, &p, 10); -#else - /* Punt and grab a 32-bit value */ - eh_ptr->content_length = strtol(value, &p, 10); -#endif - up = (guchar *)p; if (eh_ptr->content_length < 0 || p == value || diff --git a/epan/dissectors/packet-isakmp.c b/epan/dissectors/packet-isakmp.c index f8a8b7e4a3..e30e0a1ae3 100644 --- a/epan/dissectors/packet-isakmp.c +++ b/epan/dissectors/packet-isakmp.c @@ -1519,11 +1519,6 @@ typedef struct decrypt_data { } decrypt_data_t; static GHashTable *isakmp_hash = NULL; -#if GLIB_CHECK_VERSION(2,10,0) -#else -static GMemChunk *isakmp_key_data = NULL; -static GMemChunk *isakmp_decrypt_data = NULL; -#endif static ikev1_uat_data_key_t* ikev1_uat_data = NULL; static uat_t * ikev1_uat = NULL; @@ -2686,13 +2681,8 @@ dissect_isakmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) decr = (decrypt_data_t*) g_hash_table_lookup(isakmp_hash, i_cookie); if (! decr) { -#if GLIB_CHECK_VERSION(2,10,0) ic_key = g_slice_alloc(COOKIE_SIZE); decr = g_slice_alloc(sizeof(decrypt_data_t)); -#else - ic_key = g_mem_chunk_alloc(isakmp_key_data); - decr = g_mem_chunk_alloc(isakmp_decrypt_data); -#endif memcpy(ic_key, i_cookie, COOKIE_SIZE); memset(decr, 0, sizeof(decrypt_data_t)); SET_ADDRESS(&decr->initiator, AT_NONE, 0, NULL); @@ -4710,7 +4700,6 @@ static gint ikev2_key_equal_func(gconstpointer k1, gconstpointer k2) { #endif /* HAVE_LIBGCRYPT */ #ifdef HAVE_LIBGCRYPT -#if GLIB_CHECK_VERSION(2,10,0) static gboolean free_cookie(gpointer key_arg, gpointer value, gpointer user_data _U_) { @@ -4722,7 +4711,6 @@ free_cookie(gpointer key_arg, gpointer value, gpointer user_data _U_) return TRUE; } #endif -#endif static void isakmp_init_protocol(void) { @@ -4736,35 +4724,14 @@ isakmp_init_protocol(void) { #ifdef HAVE_LIBGCRYPT if (isakmp_hash) { -#if GLIB_CHECK_VERSION(2,10,0) g_hash_table_foreach_remove(isakmp_hash, free_cookie, NULL); -#endif g_hash_table_destroy(isakmp_hash); } -#if GLIB_CHECK_VERSION(2,10,0) -#else - if (isakmp_key_data) - g_mem_chunk_destroy(isakmp_key_data); - if (isakmp_decrypt_data) - g_mem_chunk_destroy(isakmp_decrypt_data); - - isakmp_key_data = g_mem_chunk_new("isakmp_key_data", - COOKIE_SIZE, 5 * COOKIE_SIZE, - G_ALLOC_AND_FREE); - isakmp_decrypt_data = g_mem_chunk_new("isakmp_decrypt_data", - sizeof(decrypt_data_t), 5 * sizeof(decrypt_data_t), - G_ALLOC_AND_FREE); -#endif isakmp_hash = g_hash_table_new(isakmp_hash_func, isakmp_equal_func); for (i = 0; i < num_ikev1_uat_data; i++) { -#if GLIB_CHECK_VERSION(2,10,0) ic_key = g_slice_alloc(COOKIE_SIZE); decr = g_slice_alloc(sizeof(decrypt_data_t)); -#else - ic_key = g_mem_chunk_alloc(isakmp_key_data); - decr = g_mem_chunk_alloc(isakmp_decrypt_data); -#endif memcpy(ic_key, ikev1_uat_data[i].icookie, COOKIE_SIZE); memset(decr, 0, sizeof(decrypt_data_t)); diff --git a/epan/dissectors/packet-synphasor.c b/epan/dissectors/packet-synphasor.c index 7e22d2aa05..799b8ea80f 100644 --- a/epan/dissectors/packet-synphasor.c +++ b/epan/dissectors/packet-synphasor.c @@ -49,10 +49,6 @@ void proto_reg_handoff_synphasor(void); static int proto_synphasor = -1; static GSList *config_frame_list = NULL; -#if ! GLIB_CHECK_VERSION(2,10,0) -static GMemChunk *frame_chunks = NULL; -#endif - /* user preferences */ static guint global_pref_tcp_port = 4712; static guint global_pref_udp_port = 4713; @@ -319,11 +315,7 @@ static config_frame* config_frame_fast(tvbuff_t *tvb) config_frame *frame; /* get a new frame and initialize it */ -#if GLIB_CHECK_VERSION(2,10,0) frame = g_slice_new(config_frame); -#else - frame = g_mem_chunk_alloc(frame_chunks); -#endif frame->config_blocks = g_array_new(FALSE, TRUE, sizeof(config_block)); @@ -437,11 +429,7 @@ static void config_frame_free(config_frame *frame) g_array_free(frame->config_blocks, TRUE); /* and the config_frame */ -#if GLIB_CHECK_VERSION(2,10,0) g_slice_free1(sizeof(config_frame), frame); -#else - g_mem_chunk_free(frame_chunks, frame); -#endif } /* called every time the user loads a capture file or starts to capture */ @@ -456,15 +444,6 @@ static void synphasor_init(void) config_frame_list = NULL; } -#if ! GLIB_CHECK_VERSION(2,10,0) - if (frame_chunks != NULL) { - g_mem_chunk_destroy(frame_chunks); - } - frame_chunks = g_mem_chunk_new("Frame_Chunks", - sizeof(config_frame), - 10*(sizeof(config_frame)), - G_ALLOC_AND_FREE); -#endif } /* the main dissection routine */ @@ -1419,4 +1398,3 @@ void proto_reg_handoff_synphasor(void) dissector_add_uint("udp.port", current_udp_port, synphasor_udp_handle); dissector_add_uint("tcp.port", current_tcp_port, synphasor_tcp_handle); } /* proto_reg_handoff_synphasor() */ - diff --git a/epan/emem.h b/epan/emem.h index f082106f21..8989abbf4e 100644 --- a/epan/emem.h +++ b/epan/emem.h @@ -26,8 +26,6 @@ #ifndef __EMEM_H__ #define __EMEM_H__ -#include "g_gnuc.h" - /** @file */ /** Initialize all the memory allocation pools described below. diff --git a/epan/epan.c b/epan/epan.c index 1eae2f184e..fb1c6494e0 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -101,7 +101,6 @@ epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_da #elif defined(HAVE_LIBGCRYPT) gcry_check_version(NULL); #endif - tvbuff_init(); tap_init(); prefs_init(); proto_init(register_all_protocols_func, register_all_handoffs_func, @@ -129,7 +128,6 @@ epan_cleanup(void) prefs_cleanup(); packet_cleanup(); oid_resolv_cleanup(); - tvbuff_cleanup(); #ifdef HAVE_LIBGNUTLS gnutls_global_deinit(); #endif diff --git a/epan/except.h b/epan/except.h index a6c6f191e7..407be9d83c 100644 --- a/epan/except.h +++ b/epan/except.h @@ -36,7 +36,6 @@ #include <setjmp.h> #include <stdlib.h> #include <assert.h> -#include <epan/g_gnuc.h> #define XCEPT_GROUP_ANY 0 #define XCEPT_CODE_ANY 0 diff --git a/epan/filesystem.c b/epan/filesystem.c index 1072d91d59..7ce3786eaf 100644 --- a/epan/filesystem.c +++ b/epan/filesystem.c @@ -1270,15 +1270,6 @@ create_persconffile_dir(char **pf_dir_path_return) return create_persconffile_profile(persconfprofile, pf_dir_path_return); } -#if ! GLIB_CHECK_VERSION(2,14,0) -static void -hash_table_get_keys(gpointer key, gpointer value _U_, gpointer user_data) -{ - GList **files = ((GList **)user_data); - *files = g_list_append (*files, key); -} -#endif - int copy_persconffile_profile(const char *toname, const char *fromname, gboolean from_global, char **pf_filename_return, char **pf_to_dir_path_return, char **pf_from_dir_path_return) @@ -1298,13 +1289,7 @@ copy_persconffile_profile(const char *toname, const char *fromname, gboolean fro from_dir = g_strdup (get_persconffile_dir(fromname)); } -#if GLIB_CHECK_VERSION(2,14,0) files = g_hash_table_get_keys(profile_files); -#else - files = NULL; - g_hash_table_foreach(profile_files, hash_table_get_keys, &files); -#endif - file = g_list_first(files); while (file) { filename = (gchar *)file->data; diff --git a/epan/ftypes/ftype-bytes.c b/epan/ftypes/ftype-bytes.c index c73c21501e..95094810cd 100644 --- a/epan/ftypes/ftype-bytes.c +++ b/epan/ftypes/ftype-bytes.c @@ -32,14 +32,10 @@ #include <epan/strutil.h> #include <epan/oids.h> -#if defined(HAVE_LIBPCRE) || GLIB_CHECK_VERSION(2,14,0) -# ifdef HAVE_LIBPCRE +#ifdef HAVE_LIBPCRE # include <pcre.h> -# endif -#define CMP_MATCHES cmp_matches -#else -#define CMP_MATCHES NULL #endif +#define CMP_MATCHES cmp_matches static void bytes_fvalue_new(fvalue_t *fv) @@ -506,7 +502,7 @@ cmp_matches(fvalue_t *fv_a, fvalue_t *fv_b) } return FALSE; } -#elif GLIB_CHECK_VERSION(2,14,0) /* GRegex */ +#else /* GRegex */ static gboolean cmp_matches(fvalue_t *fv_a, fvalue_t *fv_b) { diff --git a/epan/ftypes/ftype-pcre.c b/epan/ftypes/ftype-pcre.c index 4201dc75c4..c94f541d26 100644 --- a/epan/ftypes/ftype-pcre.c +++ b/epan/ftypes/ftype-pcre.c @@ -39,7 +39,7 @@ #include <pcre.h> -/* Create a pcre_tuple_t object based on the given string pattern */ +/* Create a pcre_tuple_t object based on the given string pattern */ static pcre_tuple_t * pcre_tuple_new(const char *value) { @@ -216,7 +216,7 @@ ftype_register_pcre(void) ftype_register(FT_PCRE, &pcre_type); } -#elif GLIB_CHECK_VERSION(2,14,0) /* No HAVE_LIBPCRE. Try falling back to GRegex. */ +#else /* No HAVE_LIBPCRE. Try falling back to GRegex. */ #include <glib.h> @@ -351,53 +351,8 @@ ftype_register_pcre(void) ftype_register(FT_PCRE, &pcre_type); } -#else /* No HAVE_LIBPCRE or GRegex */ - -void -ftype_register_pcre(void) -{ - static ftype_t pcre_type = { - FT_PCRE, /* ftype */ - "FT_PCRE", /* name */ - "Compiled Perl-Compatible Regular Expression object", /* pretty_name */ - 0, /* wire_size */ - NULL, /* new_value */ - NULL, /* free_value */ - NULL, /* val_from_unparsed */ - NULL, /* val_from_string */ - NULL, /* val_to_string_repr */ - NULL, /* len_string_repr */ - - NULL, /* set_value */ - NULL, /* set_value_uinteger */ - NULL, /* set_value_sinteger */ - NULL, /* set_value_integer64 */ - NULL, /* set_value_floating */ - - NULL, /* get_value */ - NULL, /* get_value_uinteger */ - NULL, /* get_value_sinteger */ - NULL, /* get_value_integer64 */ - NULL, /* get_value_floating */ - - NULL, /* cmp_eq */ - NULL, /* cmp_ne */ - NULL, /* cmp_gt */ - NULL, /* cmp_ge */ - NULL, /* cmp_lt */ - NULL, /* cmp_le */ - NULL, /* cmp_bitwise_and */ - NULL, /* cmp_contains */ - NULL, /* cmp_matches */ - - NULL, /* len */ - NULL, /* slice */ - }; - ftype_register(FT_PCRE, &pcre_type); -} - #endif /* HAVE_LIBPCRE */ - + /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * @@ -410,4 +365,3 @@ ftype_register_pcre(void) * vi: set shiftwidth=4 tabstop=4 noexpandtab * :indentSize=4:tabSize=4:noTabs=false: */ - diff --git a/epan/ftypes/ftype-string.c b/epan/ftypes/ftype-string.c index 11ccdf38a7..24ec502d9d 100644 --- a/epan/ftypes/ftype-string.c +++ b/epan/ftypes/ftype-string.c @@ -28,14 +28,10 @@ #include <ftypes-int.h> #include <string.h> -#if defined(HAVE_LIBPCRE) || GLIB_CHECK_VERSION(2,14,0) -# ifdef HAVE_LIBPCRE +#ifdef HAVE_LIBPCRE # include <pcre.h> -# endif -#define CMP_MATCHES cmp_matches -#else -#define CMP_MATCHES NULL #endif +#define CMP_MATCHES cmp_matches #include <ctype.h> @@ -288,7 +284,7 @@ cmp_matches(fvalue_t *fv_a, fvalue_t *fv_b) } return FALSE; } -#elif GLIB_CHECK_VERSION(2,14,0) /* GRegex */ +#else /* GRegex */ static gboolean cmp_matches(fvalue_t *fv_a, fvalue_t *fv_b) { diff --git a/epan/ftypes/ftype-tvbuff.c b/epan/ftypes/ftype-tvbuff.c index 2b1b44373f..f87c88eed5 100644 --- a/epan/ftypes/ftype-tvbuff.c +++ b/epan/ftypes/ftype-tvbuff.c @@ -28,14 +28,10 @@ #include <ftypes-int.h> #include <string.h> -#if defined(HAVE_LIBPCRE) || GLIB_CHECK_VERSION(2,14,0) -# ifdef HAVE_LIBPCRE +#ifdef HAVE_LIBPCRE # include <pcre.h> -# endif -#define CMP_MATCHES cmp_matches -#else -#define CMP_MATCHES NULL #endif +#define CMP_MATCHES cmp_matches #define tvb_is_private fvalue_gboolean1 @@ -253,7 +249,7 @@ cmp_ne(fvalue_t *fv_a, fvalue_t *fv_b) TRY { guint a_len = tvb_length(a); - + if (a_len != tvb_length(b)) { return TRUE; } @@ -277,7 +273,7 @@ cmp_gt(fvalue_t *fv_a, fvalue_t *fv_b) TRY { guint a_len = tvb_length(a); guint b_len = tvb_length(b); - + if (a_len > b_len) { return TRUE; } @@ -301,7 +297,7 @@ cmp_ge(fvalue_t *fv_a, fvalue_t *fv_b) { tvbuff_t *a = fv_a->value.tvb; tvbuff_t *b = fv_b->value.tvb; - + TRY { guint a_len = tvb_length(a); guint b_len = tvb_length(b); @@ -333,7 +329,7 @@ cmp_lt(fvalue_t *fv_a, fvalue_t *fv_b) TRY { guint a_len = tvb_length(a); guint b_len = tvb_length(b); - + if (a_len < b_len) { return TRUE; } @@ -444,7 +440,7 @@ cmp_matches(fvalue_t *fv_a, fvalue_t *fv_b) } return FALSE; } -#elif GLIB_CHECK_VERSION(2,14,0) /* GRegex */ +#else /* GRegex */ static gboolean cmp_matches(fvalue_t *fv_a, fvalue_t *fv_b) { diff --git a/epan/ftypes/ftypes-int.h b/epan/ftypes/ftypes-int.h index e84cd42d83..0e8154e400 100644 --- a/epan/ftypes/ftypes-int.h +++ b/epan/ftypes/ftypes-int.h @@ -38,8 +38,6 @@ struct _pcre_tuple_t { pcre_extra *ex; char *error; }; -#elif GLIB_CHECK_VERSION(2,14,0) /* No HAVE_LIBPCRE. Try falling back to GRegex. */ - #endif /* HAVE_LIBPCRE */ void diff --git a/epan/ftypes/ftypes.h b/epan/ftypes/ftypes.h index f4ea1ea5bc..dd95df2720 100644 --- a/epan/ftypes/ftypes.h +++ b/epan/ftypes/ftypes.h @@ -62,7 +62,7 @@ enum ftenum { FT_PCRE, /* a compiled Perl-Compatible Regular Expression object */ FT_GUID, /* GUID, UUID */ FT_OID, /* OBJECT IDENTIFIER */ - FT_EUI64, + FT_EUI64, FT_NUM_TYPES /* last item number plus one */ }; @@ -170,7 +170,7 @@ typedef struct _fvalue_t { tvbuff_t *tvb; #ifdef HAVE_LIBPCRE pcre_tuple_t *re; -#elif GLIB_CHECK_VERSION(2,14,0) /* Try falling back to GRegex. */ +#else /* Try falling back to GRegex. */ GRegex *re; #endif /* HAVE_LIBPCRE */ } value; diff --git a/epan/g_gnuc.h b/epan/g_gnuc.h deleted file mode 100644 index 3f32e32921..0000000000 --- a/epan/g_gnuc.h +++ /dev/null @@ -1,45 +0,0 @@ -/* g_gnuc.h - * Definitions of macros to conditionally do GCC optimization or code checks - * - * $Id$ - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef __G_GNUC_H__ -#define __G_GNUC_H__ - -/** - * GLib 2.6 has the ability to enable better optimization of malloc functions. - * Hide the differences between different glib versions in this G_GNUC_MALLOC macro. - */ -#if ! GLIB_CHECK_VERSION(2,6,0) - #define G_GNUC_MALLOC -#endif - -/* Glib 2.8 and later has this. */ -#if ! GLIB_CHECK_VERSION(2,8,0) - #define G_GNUC_NULL_TERMINATED -#endif - -#if ! GLIB_CHECK_VERSION(2,10,0) - #define G_GNUC_WARN_UNUSED_RESULT -#endif - -#endif /* g_gnuc.h */ diff --git a/epan/packet.c b/epan/packet.c index db33ae7a77..5bc9595c0a 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -139,12 +139,6 @@ init_dissection(void) /* Initialize protocol-specific variables. */ g_slist_foreach(init_routines, &call_init_routine, NULL); - /* Initialize the common data structures for fragment reassembly. - Must be done *after* calling init routines, as those routines - may free up space for fragments, which they find by using the - data structures that "reassemble_cleanup()" frees. */ - reassemble_init(); - /* Initialize the stream-handling tables */ stream_init(); @@ -168,12 +162,6 @@ cleanup_dissection(void) /* Cleanup protocol-specific variables. */ g_slist_foreach(init_routines, &call_init_routine, NULL); - /* Cleanup the common data structures for fragment reassembly. - Must be done *after* calling init routines, as those routines - may free up space for fragments, which they find by using the - data structures that "reassemble_cleanup()" frees. */ - reassemble_cleanup(); - /* Cleanup the stream-handling tables */ stream_cleanup(); diff --git a/epan/proto.h b/epan/proto.h index a3abafe976..0394e21344 100644 --- a/epan/proto.h +++ b/epan/proto.h @@ -51,7 +51,6 @@ #include "tvbuff.h" #include "ftypes/ftypes.h" #include "register.h" -#include "g_gnuc.h" #ifdef __cplusplus extern "C" { diff --git a/epan/reassemble.c b/epan/reassemble.c index 574a0c2cd0..52ac7b003f 100644 --- a/epan/reassemble.c +++ b/epan/reassemble.c @@ -49,14 +49,6 @@ typedef struct _dcerpc_fragment_key { e_uuid_t act_id; } dcerpc_fragment_key; -#if GLIB_CHECK_VERSION(2,10,0) -#else -static GMemChunk *fragment_key_chunk = NULL; -static GMemChunk *fragment_data_chunk = NULL; -static GMemChunk *dcerpc_fragment_key_chunk = NULL; -static int fragment_init_count = 200; -#endif - static void LINK_FRAG(fragment_data *fd_head,fragment_data *fd) { fragment_data *fd_i; @@ -74,11 +66,7 @@ static void LINK_FRAG(fragment_data *fd_head,fragment_data *fd) static void *fragment_key_copy(const void *k) { const fragment_key* key = (const fragment_key*) k; -#if GLIB_CHECK_VERSION(2,10,0) fragment_key *new_key = g_slice_new(fragment_key); -#else - fragment_key *new_key = g_mem_chunk_alloc(fragment_key_chunk); -#endif COPY_ADDRESS(&new_key->src, &key->src); COPY_ADDRESS(&new_key->dst, &key->dst); @@ -91,11 +79,7 @@ static void *dcerpc_fragment_key_copy(const void *k) { const dcerpc_fragment_key* key = (const dcerpc_fragment_key*) k; -#if GLIB_CHECK_VERSION(2,10,0) dcerpc_fragment_key *new_key = g_slice_new(dcerpc_fragment_key); -#else - dcerpc_fragment_key *new_key = g_mem_chunk_alloc(dcerpc_fragment_key_chunk); -#endif COPY_ADDRESS(&new_key->src, &key->src); COPY_ADDRESS(&new_key->dst, &key->dst); @@ -215,46 +199,22 @@ reassembled_hash(gconstpointer k) * [or dcerpc_fragment_free_key()] is called (as a consequence of * returning TRUE from this function). * If mem_chunks are used, free the address data to which the key - * refers; the the actual key and value structures get freed - * by "reassemble_cleanup()"). + * refers. */ static gboolean free_all_fragments(gpointer key_arg _U_, gpointer value, gpointer user_data _U_) { fragment_data *fd_head, *tmp_fd; -#if GLIB_CHECK_VERSION(2,10,0) /* If Glib version => 2.10 we do g_hash_table_new_full() and supply a function * to free the key and the addresses. */ -#else - fragment_key *key = key_arg; - /* - * Grr. I guess the theory here is that freeing - * something sure as heck modifies it, so you - * want to ban attempts to free it, but, alas, - * if we make the "data" field of an "address" - * structure not a "const", the compiler whines if - * we try to make it point into the data for a packet, - * as that's a "const" array (and should be, as dissectors - * shouldn't trash it). - * - * So we cast the complaint into oblivion, and rely on - * the fact that these addresses are known to have had - * their data mallocated, i.e. they don't point into, - * say, the middle of the data for a packet. - */ - g_free((gpointer)key->src.data); - g_free((gpointer)key->dst.data); -#endif for (fd_head = value; fd_head != NULL; fd_head = tmp_fd) { tmp_fd=fd_head->next; if(fd_head->data && !(fd_head->flags&FD_NOT_MALLOCED)) g_free(fd_head->data); -#if GLIB_CHECK_VERSION(2,10,0) g_slice_free(fragment_data, fd_head); -#endif } return TRUE; @@ -268,11 +228,7 @@ static fragment_data *new_head(const guint32 flags) * 'datalen' then we don't have to change the head of the list * even if we want to keep it sorted */ -#if GLIB_CHECK_VERSION(2,10,0) fd_head=g_slice_new0(fragment_data); -#else - fd_head=g_mem_chunk_alloc0(fragment_data_chunk); -#endif fd_head->flags=flags; return fd_head; @@ -281,7 +237,6 @@ static fragment_data *new_head(const guint32 flags) /* * For a reassembled-packet hash table entry, free the fragment data * to which the value refers. - * (The actual value structures get freed by "reassemble_cleanup()".) */ static gboolean free_all_reassembled_fragments(gpointer key_arg _U_, gpointer value, @@ -307,7 +262,6 @@ free_all_reassembled_fragments(gpointer key_arg _U_, gpointer value, return TRUE; } -#if GLIB_CHECK_VERSION(2,10,0) static void fragment_free_key(void *ptr) { @@ -339,7 +293,7 @@ dcerpc_fragment_free_key(void *ptr) g_slice_free(dcerpc_fragment_key, key); } } -#endif + /* * Initialize a fragment table. */ @@ -356,22 +310,15 @@ fragment_table_init(GHashTable **fragment_table) * the keys are freed by calling fragment_free_key() * and the values are freed in free_all_fragments(). * - * If mem_chunks are used, the key and value data - * are freed by "reassemble_cleanup()". free_all_fragments() + * free_all_fragments() * will free the adrress data associated with the key */ g_hash_table_foreach_remove(*fragment_table, free_all_fragments, NULL); } else { -#if GLIB_CHECK_VERSION(2,10,0) /* The fragment table does not exist. Create it */ *fragment_table = g_hash_table_new_full(fragment_hash, fragment_equal, fragment_free_key, NULL); -#else - /* The fragment table does not exist. Create it */ - *fragment_table = g_hash_table_new(fragment_hash, - fragment_equal); -#endif } } @@ -388,22 +335,15 @@ dcerpc_fragment_table_init(GHashTable **fragment_table) * the keys are freed by calling dcerpc_fragment_free_key() * and the values are freed in free_all_fragments(). * - * If mem_chunks are used, the key and value data - * are freed by "reassemble_cleanup()". free_all_fragments() + * free_all_fragments() * will free the adrress data associated with the key */ g_hash_table_foreach_remove(*fragment_table, free_all_fragments, NULL); } else { -#if GLIB_CHECK_VERSION(2,10,0) /* The fragment table does not exist. Create it */ *fragment_table = g_hash_table_new_full(dcerpc_fragment_hash, dcerpc_fragment_equal, dcerpc_fragment_free_key, NULL); -#else - /* The fragment table does not exist. Create it */ - *fragment_table = g_hash_table_new(dcerpc_fragment_hash, - dcerpc_fragment_equal); -#endif } } @@ -418,8 +358,7 @@ reassembled_table_init(GHashTable **reassembled_table) * The reassembled-packet hash table exists. * * Remove all entries and free reassembled packet - * data for each entry. (The key data is freed - * by "reassemble_cleanup()".) + * data for each entry. */ g_hash_table_foreach_remove(*reassembled_table, free_all_reassembled_fragments, NULL); @@ -430,48 +369,6 @@ reassembled_table_init(GHashTable **reassembled_table) } } -/* - * Free up all space allocated for fragment keys and data and - * reassembled keys. - */ -void -reassemble_cleanup(void) -{ -#if GLIB_CHECK_VERSION(2,10,0) -#else - if (fragment_key_chunk != NULL) - g_mem_chunk_destroy(fragment_key_chunk); - if (dcerpc_fragment_key_chunk != NULL) - g_mem_chunk_destroy(dcerpc_fragment_key_chunk); - if (fragment_data_chunk != NULL) - g_mem_chunk_destroy(fragment_data_chunk); - - fragment_key_chunk = NULL; - dcerpc_fragment_key_chunk = NULL; - fragment_data_chunk = NULL; -#endif -} - -void -reassemble_init(void) -{ -#if GLIB_CHECK_VERSION(2,10,0) -#else - fragment_key_chunk = g_mem_chunk_new("fragment_key_chunk", - sizeof(fragment_key), - fragment_init_count * sizeof(fragment_key), - G_ALLOC_AND_FREE); - dcerpc_fragment_key_chunk = g_mem_chunk_new("dcerpc_fragment_key_chunk", - sizeof(dcerpc_fragment_key), - fragment_init_count * sizeof(dcerpc_fragment_key), - G_ALLOC_AND_FREE); - fragment_data_chunk = g_mem_chunk_new("fragment_data_chunk", - sizeof(fragment_data), - fragment_init_count * sizeof(fragment_data), - G_ALLOC_ONLY); -#endif -} - /* This function cleans up the stored state and removes the reassembly data and * (with one exception) all allocated memory for matching reassembly. * diff --git a/epan/reassemble.h b/epan/reassemble.h index f23824e290..12e93a199c 100644 --- a/epan/reassemble.h +++ b/epan/reassemble.h @@ -99,7 +99,6 @@ typedef struct _fragment_data { /* a function for copying hash keys */ typedef void *(*fragment_key_copier)(const void *key); - /* * Initialize a fragment table. */ @@ -112,16 +111,6 @@ extern void dcerpc_fragment_table_init(GHashTable **fragment_table); extern void reassembled_table_init(GHashTable **reassembled_table); /* - * Free up all space allocated for fragment keys and data. - */ -void reassemble_cleanup(void); - -/* - * Initialise fragment keys and data. - */ -void reassemble_init(void); - -/* * This function adds a new fragment to the fragment hash table. * If this is the first fragment seen for this datagram, a new entry * is created in the hash table, otherwise this fragment is just added diff --git a/epan/reassemble_test.c b/epan/reassemble_test.c index fe3e62c9c7..6de2f664d7 100644 --- a/epan/reassemble_test.c +++ b/epan/reassemble_test.c @@ -1654,8 +1654,6 @@ main(int argc _U_, char **argv _U_) /* initialise stuff */ emem_init(); - tvbuff_init(); - reassemble_init(); /* a tvbuff for testing with */ data = g_malloc(DATA_LEN); diff --git a/epan/tvbtest.c b/epan/tvbtest.c index ae3aa8aea8..0a7c40eb7c 100644 --- a/epan/tvbtest.c +++ b/epan/tvbtest.c @@ -274,7 +274,7 @@ run_tests(void) tvbuff_t *tvb_comp[6]; guint comp_length[6]; int len; - + for (i = 0; i < 3; i++) { small[i] = g_new(guint8, 16); @@ -340,7 +340,7 @@ run_tests(void) /* Composite tvbuffs don't work at the moment -- tests commented out until * they do. */ - + /* One Real */ printf("Making Composite 0\n"); tvb_comp[0] = tvb_new_composite(); @@ -427,9 +427,7 @@ int main(void) { except_init(); - tvbuff_init(); run_tests(); - tvbuff_cleanup(); except_deinit(); exit(failed?1:0); } diff --git a/epan/tvbuff.c b/epan/tvbuff.c index a5d2df3330..0862ccf0e6 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -60,34 +60,6 @@ ensure_contiguous_no_exception(tvbuff_t *tvb, const gint offset, const gint leng static const guint8* ensure_contiguous(tvbuff_t *tvb, const gint offset, const 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 tvb_init(tvbuff_t *tvb, const tvbuff_type type) { @@ -136,11 +108,7 @@ tvb_new(const 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); @@ -210,11 +178,7 @@ 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 } } diff --git a/epan/tvbuff.h b/epan/tvbuff.h index cab661f861..5e75bce146 100644 --- a/epan/tvbuff.h +++ b/epan/tvbuff.h @@ -81,16 +81,6 @@ typedef struct tvbuff tvbuff_t; typedef void (*tvbuff_free_cb_t)(void*); - -/** "class" initialization. Called once during execution of program - * so that tvbuff.c can initialize its data. */ -extern void tvbuff_init(void); - -/** "class" cleanup. Called once during execution of program - * so that tvbuff.c can clean up its data. */ -extern void tvbuff_cleanup(void); - - /** Returns a pointer to a newly initialized tvbuff. Note that * tvbuff's of types TVBUFF_SUBSET and TVBUFF_COMPOSITE * require further initialization via the appropriate functions */ |