=cut
*/
-#include "image.h"
+#include "imager.h"
#include <stdio.h>
#include <stdlib.h>
char *dupl;
if (!name)
return;
- dupl = mymalloc(strlen(name)+1);
+ /* if the user has an existing string of MAXINT length then
+ the system is broken anyway */
+ dupl = mymalloc(strlen(name)+1); /* check 17jul05 tonyc */
strcpy(dupl, name);
if (argv0)
myfree(argv0);
=item i_clear_error()
+=category Error handling
+
+Clears the error stack.
+
Called by any imager function before doing any other processing.
-=cut */
+=cut
+*/
void i_clear_error() {
#ifdef IMAGER_DEBUG_MALLOC
int i;
/*
=item i_push_error(int code, char const *msg)
+=category Error handling
+
Called by an imager function to push an error message onto the stack.
No message is pushed if the stack is full (since this means someone
if (error_space[error_sp] < size) {
if (error_stack[error_sp].msg)
myfree(error_stack[error_sp].msg);
- /* memory allocated on the following line is only ever release when
+ /* memory allocated on the following line is only ever released when
we need a bigger string */
- error_stack[error_sp].msg = mymalloc(size);
+ /* size is size (len+1) of an existing string, overflow would mean
+ the system is broken anyway */
+ error_stack[error_sp].msg = mymalloc(size); /* checked 17jul05 tonyc */
error_space[error_sp] = size;
}
strcpy(error_stack[error_sp].msg, msg);
/*
=item i_push_errorvf(int code, char const *fmt, va_list ap)
+=category Error handling
+
Intended for use by higher level functions, takes a varargs pointer
and a format to produce the finally pushed error message.
/*
=item i_push_errorf(int code, char const *fmt, ...)
+=category Error handling
+
A version of i_push_error() that does printf() like formating.
=cut
va_end(ap);
}
+#ifdef IMAGER_I_FAILED
+#error "This isn't used and is untested"
+
/*
=item i_failed(char const *msg)
++sp;
}
/* we want to log the error too, build an error message to hand to
- m_fatal() */
+ i_fatal() */
total = 1; /* remember the NUL */
for (sp = error_sp; error_stack[sp].msg; ++sp) {
total += strlen(error_stack[sp].msg) + 2;
}
/* lose the extra ": " */
full[strlen(full)-2] = '\0';
- m_fatal(EXIT_FAILURE, "%s", full);
+ i_fatal(EXIT_FAILURE, "%s", full);
}
return 0;
}
+#endif
+
/*
=back