]> git.imager.perl.org - imager.git/blobdiff - error.c
update skip count
[imager.git] / error.c
diff --git a/error.c b/error.c
index 0edce898e62d8a8d5ea7c65a611e3ac133c00d9b..1737bc421f4fa428f65043bbb1300b98a58ec27e 100644 (file)
--- a/error.c
+++ b/error.c
@@ -186,11 +186,22 @@ Called by any imager function before doing any other processing.
 
 =cut */
 void i_clear_error() {
+#ifdef IMAGER_DEBUG_MALLOC
+  int i;
+
+  for (i = 0; i < ERRSTK; ++i) {
+    if (error_space[i]) {
+      myfree(error_stack[i].msg);
+      error_stack[i].msg = NULL;
+      error_space[i] = 0;
+    }
+  }
+#endif
   error_sp = ERRSTK-1;
 }
 
 /*
-=item i_push_error(char const *msg)
+=item i_push_error(int code, char const *msg)
 
 Called by an imager function to push an error message onto the stack.
 
@@ -288,7 +299,7 @@ int i_failed(int code, char const *msg) {
     fputs("error:\n", stderr);
     sp = error_sp;
     while (error_stack[sp].msg) {
-      fprintf(stderr, " %s\n", error_stack[sp]);
+      fprintf(stderr, " %s\n", error_stack[sp].msg);
       ++sp;
     }
     /* we want to log the error too, build an error message to hand to
@@ -297,7 +308,7 @@ int i_failed(int code, char const *msg) {
     for (sp = error_sp; error_stack[sp].msg; ++sp) {
       total += strlen(error_stack[sp].msg) + 2;
     }
-    full = malloc(total);
+    full = mymalloc(total);
     if (!full) {
       /* just quit, at least it's on stderr */
       exit(EXIT_FAILURE);