Use nmem_init + nmem_exit to track memory usage easier.
[yaz-moved-to-github.git] / util / marcdump.c
index b329696..4ecdc86 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: marcdump.c,v 1.48 2007-02-17 10:53:06 adam Exp $
+ * $Id: marcdump.c,v 1.50 2007-03-17 09:14:00 adam Exp $
  */
 
 #define _FILE_OFFSET_BITS 64
@@ -235,6 +235,15 @@ static void dump(const char *fname, const char *from, const char *to,
             r = fread (buf + 5, 1, rlen, inf);
             if (r < rlen)
                 break;
+            while (buf[len-1] != ISO2709_RS)
+            {
+                if (len > sizeof(buf)-2)
+                    break;
+                r = fread (buf + len, 1, 1, inf);
+                if (r != 1)
+                    break;
+                len++;
+            }
             if (split_fname)
             {
                 char fname[256];
@@ -318,7 +327,8 @@ int main (int argc, char **argv)
     const char *split_fname = 0;
     const char *leader_spec = 0;
     int write_using_libxml2 = 0;
-    
+
+    nmem_init();
 #if HAVE_LOCALE_H
     setlocale(LC_CTYPE, "");
 #endif
@@ -433,6 +443,7 @@ int main (int argc, char **argv)
     }
     if (cfile)
         fclose (cfile);
+    nmem_exit();
     if (!no)
     {
         usage(prog);