/* we never actually use the last item - it's the NULL terminator */
#define ERRSTK 20
-i_errmsg error_stack[ERRSTK];
-int error_sp = ERRSTK - 1;
+static i_errmsg error_stack[ERRSTK];
+static int error_sp = ERRSTK - 1;
/* we track the amount of space used each string, so we don't reallocate
space unless we need to.
This also means that a memory tracking library may see the memory
allocated for this as a leak. */
-int error_space[ERRSTK];
+static int error_space[ERRSTK];
static i_error_cb error_cb;
static i_failed_cb failed_cb;
=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.
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);