Ethereal-dev: [Ethereal-dev] ememify packet-enip.c

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Jaap Keuter <jaap.keuter@xxxxxxxxx>
Date: Sun, 18 Dec 2005 21:38:50 +0100 (CET)
Hi list,

Taking a random dissector from the list on the Wiki I picked
packet-enip.c. Nothing wrong with this one, I still ememified it.

Thanx,
Jaap
Index: packet-enip.c
===================================================================
--- packet-enip.c	(revision 16849)
+++ packet-enip.c	(working copy)
@@ -38,6 +38,7 @@
 #include <glib.h>
 
 #include <epan/packet.h>
+#include <epan/emem.h>
 #include <prefs.h>
 #include "packet-tcp.h"
 #include "packet-cip.h"
@@ -226,7 +227,7 @@
    }
 
    tmp = (char *)tvb_get_ptr( tvb, start, tmp_length );
-   tmp2 = (char*)g_malloc( tmp2_length );
+   tmp2 = (char *)ep_alloc( tmp2_length );
 
    tmp2start = tmp2;
 
@@ -246,12 +247,10 @@
       *tmp2++ = '.';
    }
 
-   *tmp2 = 0;
+   *tmp2 = '\0';
 
    pi = proto_tree_add_text( tree, tvb, start, length, "%s%s", str, tmp2start );
 
-   g_free( tmp2start );
-
    return( pi );
 
 } /* end of add_byte_array_text_to_proto_tree() */