aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-tpncp.c
diff options
context:
space:
mode:
authorTomas Kukosa <tomas.kukosa@siemens.com>2007-11-28 10:18:16 +0000
committerTomas Kukosa <tomas.kukosa@siemens.com>2007-11-28 10:18:16 +0000
commitff7c20938ea3da3ae7d494b35809a2387f497dec (patch)
treecff4fe924fdcfa5a5f882426b40e7fef64045810 /epan/dissectors/packet-tpncp.c
parent60686647d2aefff5065a8869899d15d212115d03 (diff)
Various changes with focus to startup speedup
The startup timeout on Win32 is reduced to 80% without assembler and to 50% with assembler usage (which is optional) proto.c - do not look up in filed tree and inserts in two steps but do it at once - next few small speedups - some often called elementary functions can be optionally implemented in assembler - dispart some functions to see more exact result from profiling packet-tpnc.c - do not reallocate memory for each filed svn path=/trunk/; revision=23643
Diffstat (limited to 'epan/dissectors/packet-tpncp.c')
-rw-r--r--epan/dissectors/packet-tpncp.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/epan/dissectors/packet-tpncp.c b/epan/dissectors/packet-tpncp.c
index b696a5e9db..acc3398068 100644
--- a/epan/dissectors/packet-tpncp.c
+++ b/epan/dissectors/packet-tpncp.c
@@ -123,6 +123,7 @@ static value_string tpncp_enums_id_vals[MAX_ENUMS_NUM][MAX_ENUM_ENTRIES];
static gchar *tpncp_enums_name_vals[MAX_ENUMS_NUM];
static gint hf_size = 1;
+static gint hf_allocated = 0;
static hf_register_info *hf = NULL;
static hf_register_info hf_tpncp[] = {
{
@@ -575,9 +576,10 @@ static gint init_tpncp_data_fields_info(tpncp_data_field_info *data_fields_info,
if (!was_registered) {
/* Register non-standard data should be done only once. */
+ hf_allocated = hf_size+array_length(hf_tpncp)-1;
+ if ((hf = (hf_register_info *)g_realloc(hf, hf_allocated * sizeof(hf_register_info))) == NULL)
+ return (-1);
for (index = 0; index < array_length(hf_tpncp); index++) {
- if ((hf = (hf_register_info *)realloc(hf, hf_size*sizeof(hf_register_info))) == NULL)
- return (-1);
memcpy(hf + (hf_size - 1), hf_tpncp + index, sizeof(hf_register_info));
hf_size++;
}
@@ -616,8 +618,8 @@ static gint init_tpncp_data_fields_info(tpncp_data_field_info *data_fields_info,
current_data_id = data_id;
}
else {
- if ((current_tpncp_data_field_info->p_next =
- (tpncp_data_field_info *)calloc(1, sizeof(tpncp_data_field_info)))
+ if ((current_tpncp_data_field_info->p_next =
+ (tpncp_data_field_info *)g_malloc0(sizeof(tpncp_data_field_info)))
== NULL)
return (-1);
current_tpncp_data_field_info = current_tpncp_data_field_info->p_next;
@@ -655,8 +657,11 @@ static gint init_tpncp_data_fields_info(tpncp_data_field_info *data_fields_info,
break;
}
/* Register initialized hf_register_info in global database. */
- if ((hf = (hf_register_info *)realloc(hf, hf_size*sizeof(hf_register_info))) == NULL)
- return (-1);
+ if (hf_size > hf_allocated) {
+ hf_allocated += 1024;
+ if ((hf = (hf_register_info *)g_realloc(hf, hf_allocated * sizeof(hf_register_info))) == NULL)
+ return (-1);
+ }
memcpy(hf + hf_size - 1, &hf_entr, sizeof(hf_register_info));
hf_size++;
current_tpncp_data_field_info->tpncp_data_field_sign = tpncp_data_field_sign;