Glib docs recommend using the slice API if you know you won't need to realloc.
[metze/wireshark/wip.git] / editcap.c
index f1fdf7dcb51844ac3aa81d17158fa5289a9348c0..2d4b18ef5e58f5344f8ea4ef327d762a9c06df8d 100644 (file)
--- a/editcap.c
+++ b/editcap.c
@@ -52,8 +52,6 @@
 #include <unistd.h>
 #endif
 
-
-
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
 # include "wsutil/strptime.h"
 #endif
 
+#include <wsutil/privileges.h>
+
+/*
+ * The symbols declared in the below are exported from libwireshark,
+ * but we don't want to link whole libwireshark to editcap.
+ * We link the object directly instead and this needs a little trick
+ * with the WS_BUILD_DLL #define.
+ */
+#define WS_BUILD_DLL
+#define RESET_SYMBOL_EXPORT /* wsutil/wsgetopt.h set export behavior above. */
 #include "epan/crypt/md5.h"
 #include "epan/plugins.h"
 #include "epan/report_err.h"
 #include "epan/filesystem.h"
-#include <wsutil/privileges.h>
 #include "epan/nstime.h"
+#undef WS_BUILD_DLL
+#define RESET_SYMBOL_EXPORT
 
 #include "svnversion.h"
 
@@ -168,7 +177,7 @@ static gchar *
 abs_time_to_str_with_sec_resolution(const struct wtap_nstime *abs_time)
 {
     struct tm *tmp;
-    gchar *buf = g_malloc(16);
+    gchar *buf = (gchar *)g_malloc(16);
 
 #if (defined _WIN32) && (_MSC_VER < 1500)
     /* calling localtime() on MSVC 2005 with huge values causes it to crash */
@@ -785,7 +794,7 @@ list_capture_types(void) {
     struct string_elem *captypes;
     GSList *list = NULL;
 
-    captypes = g_malloc(sizeof(struct string_elem) * WTAP_NUM_FILE_TYPES);
+    captypes = g_new(struct string_elem,WTAP_NUM_FILE_TYPES);
     fprintf(stderr, "editcap: The available capture file types for the \"-F\" flag are:\n");
     for (i = 0; i < WTAP_NUM_FILE_TYPES; i++) {
       if (wtap_dump_can_open(i)) {