aboutsummaryrefslogtreecommitdiff
path: root/src/diag.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-01-08 15:31:17 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2016-01-08 16:17:35 +0200
commit489432d354d88049afe4af54c29965d382d67f7a (patch)
tree84725496a92564824f75f0a2edd5a595411ffab2 /src/diag.c
parent3325fed2895f079486b88c65409c73153fec306f (diff)
downloadpies-489432d354d88049afe4af54c29965d382d67f7a.tar.gz
pies-489432d354d88049afe4af54c29965d382d67f7a.tar.bz2
Uniformly use grecs memory management functions.
* gnulib.modules: Remove unneded modules. * ident/ident.h: Remove xalloc.h, include errno.h * ident/ident.c: Use standard allocation functions instead of x* * ident/pam.c: Remove. * ident/provider.c: Remove. * ident/system.c: Remove. * src/meta.c: Remove. * src/Makefile.am: Remove meta.c * src/progman.c: Use grecs_* allocation functions instead of x*. (notify): Use wordsplit to expand variables within message. Rename variables: program-name to program_name; canonical-program-name to canonical_program_name. * doc/pies.texi: Update. * src/depmap.c: Use grecs_* allocation functions instead of x*. (depmap_end): New function. * src/diag.c (logmsg_vprintf): Use grecs_txtacc instead of obstack. * src/pies.h (depmap_end): New proto. Remove unused includes. * src/acl.c: Use grecs_* allocation functions instead of x*. * src/ctl.c: Likewise. * src/inetd.c: Likewise. * src/limits.c: Likewise. * src/meta1gram.y: Likewise. * src/meta1lex.l: Likewise. * src/pies.c: Likewise. * src/socket.c: Likewise. * src/sysvinit.c: Likewise. * src/userprivs.c: Likewise.
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.