aboutsummaryrefslogtreecommitdiff
path: root/src/diag.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/diag.c')
-rw-r--r--src/diag.c48
1 files changed, 25 insertions, 23 deletions
diff --git a/src/diag.c b/src/diag.c
index 165cc2f..65d9562 100644
--- a/src/diag.c
+++ b/src/diag.c
@@ -15,7 +15,6 @@
along with GNU Pies. If not, see <http://www.gnu.org/licenses/>. */
#include "pies.h"
-#include "xvasprintf.h"
unsigned debug_level;
int source_info_option;
@@ -103,39 +102,42 @@ debug_msg (const char *fmt, ...)
}
-static struct obstack log_stk;
-static int log_stk_init;
void
logmsg_vprintf (int prio, const char *fmt, va_list ap)
{
- char *str, *p;
-
- str = xvasprintf (fmt, ap);
+ char *p, *t, *str;
+ static char *buf = NULL;
+ static size_t len = 0;
+ static struct grecs_txtacc *log_acc;
- if (!log_stk_init)
+ if (grecs_vasprintf (&buf, &len, fmt, ap))
{
- obstack_init (&log_stk);
- log_stk_init = 1;
+ logmsg (LOG_CRIT, _("out of memory trying to log a message"));
+ return;
}
- for (p = str; *p; )
+ if (!log_acc)
+ log_acc = grecs_txtacc_create ();
+
+ str = buf;
+
+ while (str)
{
- size_t len = strcspn (p, "\n");
- if (len)
- obstack_grow (&log_stk, p, len);
- p += len;
- if (*p)
+ p = strchr (str, '\n');
+ if (p)
{
- char *msg;
-
- obstack_1grow (&log_stk, 0);
- msg = obstack_finish (&log_stk);
- logmsg (prio, "%s", msg);
- obstack_free (&log_stk, msg);
- p++;
+ *p++ = 0;
+ if (!*p)
+ p = NULL;
+ grecs_txtacc_grow_char (log_acc, 0);
+ t = grecs_txtacc_finish (log_acc, 0);
+ logmsg (prio, "%s", t);
+ grecs_txtacc_free_string (log_acc, t);
}
+ else
+ grecs_txtacc_grow_string (log_acc, str);
+ str = p;
}
- free (str);
}
void

Return to:

Send suggestions and report system problems to the System administrator.