aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2005-08-12 10:50:55 +0000
committerRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2005-08-12 10:50:55 +0000
commit234f09c6637f6e211cdd6059189b07c490554c38 (patch)
treea86d3896cad28dcfed5bb550b013def6304812c4 /epan
parente9e87bb4a6c7c751ea95c83b421ca2b7c64b46cf (diff)
more gmemchunk -> se_alloc() improvements
svn path=/trunk/; revision=15312
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-rtcp.c28
-rw-r--r--epan/dissectors/packet-rtp.c22
-rw-r--r--epan/dissectors/packet-rtsp.c22
3 files changed, 11 insertions, 61 deletions
diff --git a/epan/dissectors/packet-rtcp.c b/epan/dissectors/packet-rtcp.c
index d64f702488..9cbf7f4485 100644
--- a/epan/dissectors/packet-rtcp.c
+++ b/epan/dissectors/packet-rtcp.c
@@ -63,6 +63,7 @@
#include <epan/conversation.h>
#include <epan/prefs.h>
+#include <epan/emem.h>
/* Version is the first 2 bits of the first octet*/
@@ -354,9 +355,6 @@ static void add_roundtrip_delay_info(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, guint frame, guint delay);
-/* Memory chunk for storing conversation and per-packet info */
-static GMemChunk *rtcp_conversations = NULL;
-
/* Set up an RTCP conversation using the info given */
void rtcp_add_address( packet_info *pinfo,
address *addr, int port,
@@ -408,7 +406,7 @@ void rtcp_add_address( packet_info *pinfo,
*/
if ( ! p_conv_data ) {
/* Create conversation data */
- p_conv_data = g_mem_chunk_alloc(rtcp_conversations);
+ p_conv_data = se_alloc(sizeof(struct _rtcp_conversation_info));
if (!p_conv_data)
{
return;
@@ -426,19 +424,6 @@ void rtcp_add_address( packet_info *pinfo,
p_conv_data->setup_frame_number = setup_frame_number;
}
-static void rtcp_init( void )
-{
- /* (Re)allocate mem chunk for conversations */
- if (rtcp_conversations)
- {
- g_mem_chunk_destroy(rtcp_conversations);
- }
- rtcp_conversations = g_mem_chunk_new("rtcp_conversations",
- sizeof(struct _rtcp_conversation_info),
- 20 * sizeof(struct _rtcp_conversation_info),
- G_ALLOC_ONLY);
-}
-
static gboolean
dissect_rtcp_heur( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
{
@@ -1363,7 +1348,7 @@ void show_setup_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (p_conv_data)
{
/* Save this conversation info into packet info */
- p_conv_packet_data = g_mem_chunk_alloc(rtcp_conversations);
+ p_conv_packet_data = se_alloc(sizeof(struct _rtcp_conversation_info));
if (!p_conv_packet_data)
{
return;
@@ -1457,7 +1442,7 @@ static void remember_outgoing_sr(packet_info *pinfo, long lsr)
if (!p_conv_data)
{
/* Allocate memory for data */
- p_conv_data = g_mem_chunk_alloc(rtcp_conversations);
+ p_conv_data = se_alloc(sizeof(struct _rtcp_conversation_info));
if (!p_conv_data)
{
/* Give up if couldn't allocate space for memory */
@@ -1484,7 +1469,7 @@ static void remember_outgoing_sr(packet_info *pinfo, long lsr)
/* Will use/create packet info */
if (!p_packet_data)
{
- p_packet_data = g_mem_chunk_alloc(rtcp_conversations);
+ p_packet_data = se_alloc(sizeof(struct _rtcp_conversation_info));
if (!p_packet_data)
{
/* Give up if allocation fails */
@@ -1560,7 +1545,7 @@ static void calculate_roundtrip_delay(tvbuff_t *tvb, packet_info *pinfo,
if (!p_packet_data)
{
/* Create packet info if it doesn't exist */
- p_packet_data = g_mem_chunk_alloc(rtcp_conversations);
+ p_packet_data = se_alloc(sizeof(struct _rtcp_conversation_info));
if (!p_packet_data)
{
/* Give up if allocation fails */
@@ -2994,7 +2979,6 @@ proto_register_rtcp(void)
MIN_ROUNDTRIP_TO_REPORT_DEFAULT, &global_rtcp_show_roundtrip_calculation_minimum);
- register_init_routine( &rtcp_init );
}
void
diff --git a/epan/dissectors/packet-rtp.c b/epan/dissectors/packet-rtp.c
index 9098672ef2..60a28e9c66 100644
--- a/epan/dissectors/packet-rtp.c
+++ b/epan/dissectors/packet-rtp.c
@@ -67,6 +67,7 @@
#include <epan/tap.h>
#include <epan/prefs.h>
+#include <epan/emem.h>
static dissector_handle_t rtp_handle;
static dissector_handle_t stun_handle;
@@ -134,9 +135,6 @@ static gboolean global_rtp_show_setup_info = TRUE;
/* Try heuristic RTP decode */
static gboolean global_rtp_heur = FALSE;
-/* Memory chunk for storing conversation and per-packet info */
-static GMemChunk *rtp_conversations = NULL;
-
/*
* Fields in the first octet of the RTP header.
*/
@@ -303,7 +301,7 @@ void rtp_add_address(packet_info *pinfo,
*/
if ( ! p_conv_data ) {
/* Create conversation data */
- p_conv_data = g_mem_chunk_alloc(rtp_conversations);
+ p_conv_data = se_alloc(sizeof(struct _rtp_conversation_info));
p_conv_data->rtp_dyn_payload = NULL;
conversation_add_proto_data(p_conv, proto_rtp, p_conv_data);
@@ -321,19 +319,6 @@ void rtp_add_address(packet_info *pinfo,
p_conv_data->rtp_dyn_payload = rtp_dyn_payload;
}
-static void rtp_init( void )
-{
- /* (Re)allocate mem chunk for conversations */
- if (rtp_conversations)
- {
- g_mem_chunk_destroy(rtp_conversations);
- }
- rtp_conversations = g_mem_chunk_new("rtp_conversations",
- sizeof(struct _rtp_conversation_info),
- 20 * sizeof(struct _rtp_conversation_info),
- G_ALLOC_ONLY);
-}
-
static gboolean
dissect_rtp_heur( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
{
@@ -777,7 +762,7 @@ static void get_conv_info(packet_info *pinfo, struct _rtp_info *rtp_info)
if (p_conv_data) {
/* Save this conversation info into packet info */
- p_conv_packet_data = g_mem_chunk_alloc(rtp_conversations);
+ p_conv_packet_data = se_alloc(sizeof(struct _rtp_conversation_info));
strcpy(p_conv_packet_data->method, p_conv_data->method);
p_conv_packet_data->frame_number = p_conv_data->frame_number;
p_conv_packet_data->rtp_dyn_payload = p_conv_data->rtp_dyn_payload;
@@ -1104,7 +1089,6 @@ proto_register_rtp(void)
"If an RTP version 0 packet is encountered, it can be treated as an invalid packet or a STUN packet",
&global_rtp_version0_type,
rtp_version0_types, FALSE);
- register_init_routine( &rtp_init );
}
void
diff --git a/epan/dissectors/packet-rtsp.c b/epan/dissectors/packet-rtsp.c
index ea142ebc04..37080ac18e 100644
--- a/epan/dissectors/packet-rtsp.c
+++ b/epan/dissectors/packet-rtsp.c
@@ -46,6 +46,7 @@
#include <epan/conversation.h>
#include <epan/strutil.h>
#include "packet-e164.h"
+#include <epan/emem.h>
static int proto_rtsp = -1;
@@ -71,9 +72,6 @@ static dissector_handle_t rdt_handle;
void proto_reg_handoff_rtsp(void);
-static GMemChunk *rtsp_vals = NULL;
-#define rtsp_hash_init_count 20
-
/*
* desegmentation of RTSP headers
* (when we are over TCP or another protocol providing the desegmentation API)
@@ -447,7 +445,7 @@ rtsp_create_conversation(packet_info *pinfo, const guchar *line_begin,
}
data = conversation_get_proto_data(conv, proto_rtsp);
if (!data) {
- data = g_mem_chunk_alloc(rtsp_vals);
+ data = se_alloc(sizeof(rtsp_conversation_data_t));
conversation_add_proto_data(conv, proto_rtsp, data);
}
@@ -1200,21 +1198,6 @@ dissect_rtsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
}
-static void
-rtsp_init(void)
-{
-/* Routine to initialize rtsp protocol before each capture or filter pass. */
-/* Release any memory if needed. Then setup the memory chunks. */
-
- if (rtsp_vals)
- g_mem_chunk_destroy(rtsp_vals);
-
- rtsp_vals = g_mem_chunk_new("rtsp_vals",
- sizeof(rtsp_conversation_data_t),
- rtsp_hash_init_count * sizeof(rtsp_conversation_data_t),
- G_ALLOC_AND_FREE);
-}
-
void
proto_register_rtsp(void)
{
@@ -1289,7 +1272,6 @@ proto_register_rtsp(void)
"of a request spanning multiple TCP segments",
&rtsp_desegment_body);
- register_init_routine(rtsp_init); /* register re-init routine */
}
void