static void
cu_errorreporter(const char *fmt, va_list ap)
{
- char *msg;
-
- /** This is a GNU extension.
- * Dunno how to handle errors here.
- */
- if (!lw_vasprintf (&msg, fmt, ap))
- {
- va_end (ap);
- return;
- }
-
- strncpy(cu_error_msg, msg, MAX_CUNIT_ERROR_LENGTH);
- lwfree(msg);
+ vsnprintf (cu_error_msg, MAX_CUNIT_MSG_LENGTH, fmt, ap);
+ cu_error_msg[MAX_CUNIT_MSG_LENGTH]='\0';
}
void
lwreporter lwnotice_var = default_noticereporter;
lwreporter lwerror_var = default_errorreporter;
+#define LW_MSG_MAXLEN 256
+
static char *lwgeomTypeName[] =
{
"Unknown",
static void
default_noticereporter(const char *fmt, va_list ap)
{
- char *msg;
-
- /*
- * This is a GNU extension.
- * Dunno how to handle errors here.
- */
- if (!lw_vasprintf (&msg, fmt, ap))
- {
- va_end (ap);
- return;
- }
+ char *msg[LW_MSG_MAXLEN+1];
+ vsnprintf (msg, LW_MSG_MAXLEN, fmt, ap);
+ msg[LW_MSG_MAXLEN]='\0';
printf("%s\n", msg);
- free(msg);
}
static void
default_errorreporter(const char *fmt, va_list ap)
{
- char *msg;
-
- /*
- * This is a GNU extension.
- * Dunno how to handle errors here.
- */
- if (!lw_vasprintf (&msg, fmt, ap))
- {
- va_end (ap);
- return;
- }
+ char *msg[LW_MSG_MAXLEN+1];
+ vsnprintf (msg, LW_MSG_MAXLEN, fmt, ap);
+ msg[LW_MSG_MAXLEN]='\0';
fprintf(stderr, "%s\n", msg);
- free(msg);
exit(1);
}