Removed the DEBUG_MEMORY_LEAKS framework because we do this with Valgrind now.
[citadel.git] / citadel / sysdep.c
index 4c19d2933586aed277a011fd3170fbc6cc18a442..e16c8a50b2228371d28a926b72fd17bb517ece86 100644 (file)
 #include "control.h"
 
 
-#ifdef DEBUG_MEMORY_LEAKS
-struct igheap {
-       struct igheap *next;
-       char file[32];
-       int line;
-       void *block;
-};
-
-struct igheap *igheap = NULL;
-#endif
-
-
 /*
  * Signal handler to shut down the server.
  */
@@ -1487,112 +1475,3 @@ int SyslogFacility(char *name)
        }
        return LOG_DAEMON;
 }
-
-
-/********** MEM CHEQQER ***********/
-
-#ifdef DEBUG_MEMORY_LEAKS
-
-#undef malloc
-#undef realloc
-#undef strdup
-#undef free
-
-void *tracked_malloc(size_t size, char *file, int line) {
-       struct igheap *thisheap;
-       void *block;
-
-       block = malloc(size);
-       if (block == NULL) return(block);
-
-       thisheap = malloc(sizeof(struct igheap));
-       if (thisheap == NULL) {
-               free(block);
-               return(NULL);
-       }
-
-       thisheap->block = block;
-       strcpy(thisheap->file, file);
-       thisheap->line = line;
-       
-       begin_critical_section(S_DEBUGMEMLEAKS);
-       thisheap->next = igheap;
-       igheap = thisheap;
-       end_critical_section(S_DEBUGMEMLEAKS);
-
-       return(block);
-}
-
-
-void *tracked_realloc(void *ptr, size_t size, char *file, int line) {
-       struct igheap *thisheap;
-       void *block;
-
-       block = realloc(ptr, size);
-       if (block == NULL) return(block);
-
-       thisheap = malloc(sizeof(struct igheap));
-       if (thisheap == NULL) {
-               free(block);
-               return(NULL);
-       }
-
-       thisheap->block = block;
-       strcpy(thisheap->file, file);
-       thisheap->line = line;
-       
-       begin_critical_section(S_DEBUGMEMLEAKS);
-       thisheap->next = igheap;
-       igheap = thisheap;
-       end_critical_section(S_DEBUGMEMLEAKS);
-
-       return(block);
-}
-
-
-
-void tracked_free(void *ptr) {
-       struct igheap *thisheap;
-       struct igheap *trash;
-
-       free(ptr);
-
-       if (igheap == NULL) return;
-       begin_critical_section(S_DEBUGMEMLEAKS);
-       for (thisheap = igheap; thisheap != NULL; thisheap = thisheap->next) {
-               if (thisheap->next != NULL) {
-                       if (thisheap->next->block == ptr) {
-                               trash = thisheap->next;
-                               thisheap->next = thisheap->next->next;
-                               free(trash);
-                       }
-               }
-       }
-       if (igheap->block == ptr) {
-               trash = igheap;
-               igheap = igheap->next;
-               free(trash);
-       }
-       end_critical_section(S_DEBUGMEMLEAKS);
-}
-
-char *tracked_strdup(const char *s, char *file, int line) {
-       char *ptr;
-
-       if (s == NULL) return(NULL);
-       ptr = tracked_malloc(strlen(s) + 1, file, line);
-       if (ptr == NULL) return(NULL);
-       strncpy(ptr, s, strlen(s));
-       return(ptr);
-}
-
-void dump_heap(void) {
-       struct igheap *thisheap;
-
-       for (thisheap = igheap; thisheap != NULL; thisheap = thisheap->next) {
-               syslog(LOG_CRIT, "UNFREED: %30s : %d\n",
-                       thisheap->file, thisheap->line);
-       }
-}
-
-#endif /*  DEBUG_MEMORY_LEAKS */