Public nmem_print_list (for debugging).
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 9 May 2000 10:55:05 +0000 (10:55 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 9 May 2000 10:55:05 +0000 (10:55 +0000)
include/yaz/nmem.h
util/nmem.c

index 7040b98..595156b 100644 (file)
  * OF THIS SOFTWARE.
  *
  * $Log: nmem.h,v $
- * Revision 1.2  2000-02-28 11:20:06  adam
+ * Revision 1.3  2000-05-09 10:55:05  adam
+ * Public nmem_print_list (for debugging).
+ *
+ * Revision 1.2  2000/02/28 11:20:06  adam
  * Using autoconf. New definitions: YAZ_BEGIN_CDECL/YAZ_END_CDECL.
  *
  * Revision 1.1  1999/11/30 13:47:11  adam
@@ -51,7 +54,7 @@
 #define NMEM_H
 #include <yaz/yconfig.h>
 
-#define NMEM_DEBUG 0
+#define NMEM_DEBUG 1
 
 #ifndef NMEM_DEBUG
 #define NMEM_DEBUG 0
@@ -93,12 +96,16 @@ YAZ_EXPORT void *nmem_malloc_f(const char *file, int line, NMEM n, int size);
 #define nmem_destroy(x) nmem_destroy_f(__FILE__, __LINE__, (x))
 #define nmem_malloc(x, y) nmem_malloc_f(__FILE__, __LINE__, (x), (y))
 
+YAZ_EXPORT void nmem_print_list (void);
+
 #else
 
 YAZ_EXPORT NMEM nmem_create(void);
 YAZ_EXPORT void nmem_destroy(NMEM n);
 YAZ_EXPORT void *nmem_malloc(NMEM n, int size);
 
+#define nmem_print_list
+
 #endif
 
 YAZ_EXPORT void nmem_init (void);
index a9646fb..beaac98 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: nmem.c,v $
- * Revision 1.22  2000-05-03 22:00:00  adam
+ * Revision 1.23  2000-05-09 10:55:05  adam
+ * Public nmem_print_list (for debugging).
+ *
+ * Revision 1.22  2000/05/03 22:00:00  adam
  * Reference counter (if multiple modules are init/freeing nmem).
  *
  * Revision 1.21  2000/02/29 13:44:55  adam
@@ -125,14 +128,14 @@ static int nmem_active_no = 0;
 static int nmem_init_flag = 0;
 
 #if NMEM_DEBUG
-struct nmem_debug {
+struct nmem_debug_info {
     void *p;
     char file[40];
     int line;
-    struct nmem_debug *next;
+    struct nmem_debug_info *next;
 };
   
-struct nmem_debug *nmem_debug_list = 0;  
+struct nmem_debug_info *nmem_debug_list = 0;  
 #endif
 
 static void free_block(nmem_block *p)
@@ -147,12 +150,13 @@ static void free_block(nmem_block *p)
 #if NMEM_DEBUG
 void nmem_print_list (void)
 {
-    struct nmem_debug *p;
+    struct nmem_debug_info *p;
 
     yaz_log (LOG_DEBUG, "nmem print list");
     NMEM_ENTER;
     for (p = nmem_debug_list; p; p = p->next)
-       yaz_log (LOG_DEBUG, " %s:%d p=%p", p->file, p->line, p->p);
+       yaz_log (LOG_LOG, " %s:%d p=%p size=%d", p->file, p->line, p->p,
+                nmem_total(p->p));
     NMEM_LEAVE;
 }
 #endif
@@ -265,7 +269,7 @@ NMEM nmem_create(void)
 {
     NMEM r;
 #if NMEM_DEBUG
-    struct nmem_debug *debug_p;
+    struct nmem_debug_info *debug_p;
 #endif
     
     NMEM_ENTER;
@@ -312,7 +316,7 @@ void nmem_destroy(NMEM n)
 #endif
 {
 #if NMEM_DEBUG
-    struct nmem_debug **debug_p;
+    struct nmem_debug_info **debug_p;
     int ok = 0;
 #endif
     if (!n)
@@ -325,7 +329,7 @@ void nmem_destroy(NMEM n)
     for (debug_p = &nmem_debug_list; *debug_p; debug_p = &(*debug_p)->next)
        if ((*debug_p)->p == n)
        {
-           struct nmem_debug *debug_save = *debug_p;
+           struct nmem_debug_info *debug_save = *debug_p;
            *debug_p = (*debug_p)->next;
            xfree (debug_save);
            ok = 1;