Commit f66b8003 authored by Matteo Quintiliani's avatar Matteo Quintiliani

debugging memory leaks controlled by --enable-memdebug of configure


git-svn-id: file:///home/quintiliani/svncopy/nmxptool/trunk@977 3cd66e75-5955-46cb-a940-c26e5fc5497d
parent 94269845
...@@ -65,6 +65,12 @@ AC_SEARCH_LIBS(rt, nanosleep, , ...@@ -65,6 +65,12 @@ AC_SEARCH_LIBS(rt, nanosleep, ,
AC_SEARCH_LIBS(ws2_32, puts, , AC_SEARCH_LIBS(ws2_32, puts, ,
[AC_CHECK_LIB(ws2_32, puts, LIBS="$LIBS -lws2_32", , -lws2_32)]) [AC_CHECK_LIB(ws2_32, puts, LIBS="$LIBS -lws2_32", , -lws2_32)])
AC_ARG_ENABLE([memdebug],
[AS_HELP_STRING([--enable-memdebug], [compile nmxptool for debugging memory leaks])],
[],
[enable_memdebug=no]
)
AC_ARG_ENABLE([libmseed], AC_ARG_ENABLE([libmseed],
[AS_HELP_STRING([--disable-libmseed], [disable saving data in mini-SEED records])], [AS_HELP_STRING([--disable-libmseed], [disable saving data in mini-SEED records])],
[], [],
...@@ -100,6 +106,15 @@ AM_CONDITIONAL(ENABLE_WINSOURCES, test x$WINSOURCES != x) ...@@ -100,6 +106,15 @@ AM_CONDITIONAL(ENABLE_WINSOURCES, test x$WINSOURCES != x)
AM_PROG_LIBTOOL AM_PROG_LIBTOOL
# memdebug check.
AS_IF([test "x$enable_memdebug" != xno],
[
CFLAGS="$CFLAGS -DNMXP_MEM_DEBUG"
AC_MSG_WARN([memdebug has been enabled!])
]
)
AM_CONDITIONAL(ENABLE_MEMDEBUG, test x$enable_memdebug != xno)
# Checks for header files. # Checks for header files.
AC_HEADER_STDC AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h unistd.h]) AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h unistd.h])
......
...@@ -14,9 +14,20 @@ ...@@ -14,9 +14,20 @@
#ifndef NMXP_MEMORY_H #ifndef NMXP_MEMORY_H
#define NMXP_MEMORY_H 1 #define NMXP_MEMORY_H 1
#ifndef NMXP_MEM_DEBUG
#define NMXP_MEM_MALLOC(size) malloc(size)
#define NMXP_MEM_STRDUP(str) strdup(str)
#define NMXP_MEM_FREE(ptr) free(ptr)
#define NMXP_MEM_PRINT_PTR { }
#else
#define NMXP_MEM_MALLOC(size) nmxp_mem_malloc(size, __FILE__, __LINE__) #define NMXP_MEM_MALLOC(size) nmxp_mem_malloc(size, __FILE__, __LINE__)
#define NMXP_MEM_STRDUP(str) nmxp_mem_strdup(str, __FILE__, __LINE__) #define NMXP_MEM_STRDUP(str) nmxp_mem_strdup(str, __FILE__, __LINE__)
#define NMXP_MEM_FREE(ptr) nmxp_mem_free(ptr, __FILE__, __LINE__) #define NMXP_MEM_FREE(ptr) nmxp_mem_free(ptr, __FILE__, __LINE__)
#define NMXP_MEM_PRINT_PTR nmxp_mem_print_ptr()
#include <stdlib.h> #include <stdlib.h>
...@@ -55,3 +66,5 @@ void nmxp_mem_print_ptr(); ...@@ -55,3 +66,5 @@ void nmxp_mem_print_ptr();
#endif #endif
#endif
...@@ -7,10 +7,12 @@ ...@@ -7,10 +7,12 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy * Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it * quintiliani@ingv.it
* *
* $Id: nmxp_memory.c,v 1.2 2008-03-28 13:21:24 mtheo Exp $ * $Id: nmxp_memory.c,v 1.3 2008-03-28 16:27:15 mtheo Exp $
* *
*/ */
#ifdef NMXP_MEM_DEBUG
#include "nmxp_memory.h" #include "nmxp_memory.h"
#include "nmxp_log.h" #include "nmxp_log.h"
...@@ -169,4 +171,5 @@ void nmxp_mem_free(void *ptr, char *source_file, int line) { ...@@ -169,4 +171,5 @@ void nmxp_mem_free(void *ptr, char *source_file, int line) {
} }
} }
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment