summaryrefslogtreecommitdiff
path: root/isisd/isis_misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'isisd/isis_misc.c')
-rw-r--r--isisd/isis_misc.c42
1 files changed, 9 insertions, 33 deletions
diff --git a/isisd/isis_misc.c b/isisd/isis_misc.c
index 0a42adea37..d4c38efaf3 100644
--- a/isisd/isis_misc.c
+++ b/isisd/isis_misc.c
@@ -23,6 +23,7 @@
#include <zebra.h>
+#include "printfrr.h"
#include "stream.h"
#include "vty.h"
#include "hash.h"
@@ -511,42 +512,14 @@ void zlog_dump_data(void *data, int len)
return;
}
-static char *qasprintf(const char *format, va_list ap)
-{
- va_list aq;
- va_copy(aq, ap);
-
- int size = 0;
- char *p = NULL;
-
- size = vsnprintf(p, size, format, ap);
-
- if (size < 0) {
- va_end(aq);
- return NULL;
- }
-
- size++;
- p = XMALLOC(MTYPE_TMP, size);
-
- size = vsnprintf(p, size, format, aq);
- va_end(aq);
-
- if (size < 0) {
- XFREE(MTYPE_TMP, p);
- return NULL;
- }
-
- return p;
-}
-
void log_multiline(int priority, const char *prefix, const char *format, ...)
{
+ char shortbuf[256];
va_list ap;
char *p;
va_start(ap, format);
- p = qasprintf(format, ap);
+ p = asnprintfrr(MTYPE_TMP, shortbuf, sizeof(shortbuf), format, ap);
va_end(ap);
if (!p)
@@ -558,16 +531,18 @@ void log_multiline(int priority, const char *prefix, const char *format, ...)
zlog(priority, "%s%s", prefix, line);
}
- XFREE(MTYPE_TMP, p);
+ if (p != shortbuf)
+ XFREE(MTYPE_TMP, p);
}
void vty_multiline(struct vty *vty, const char *prefix, const char *format, ...)
{
+ char shortbuf[256];
va_list ap;
char *p;
va_start(ap, format);
- p = qasprintf(format, ap);
+ p = asnprintfrr(MTYPE_TMP, shortbuf, sizeof(shortbuf), format, ap);
va_end(ap);
if (!p)
@@ -579,7 +554,8 @@ void vty_multiline(struct vty *vty, const char *prefix, const char *format, ...)
vty_out(vty, "%s%s\n", prefix, line);
}
- XFREE(MTYPE_TMP, p);
+ if (p != shortbuf)
+ XFREE(MTYPE_TMP, p);
}
void vty_out_timestr(struct vty *vty, time_t uptime)