aboutsummaryrefslogtreecommitdiff
path: root/include/lib_strbuf.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/lib_strbuf.h')
-rw-r--r--include/lib_strbuf.h32
1 files changed, 18 insertions, 14 deletions
diff --git a/include/lib_strbuf.h b/include/lib_strbuf.h
index 5aa0eb0a6d72..5ee92d6f8341 100644
--- a/include/lib_strbuf.h
+++ b/include/lib_strbuf.h
@@ -1,28 +1,32 @@
/*
* lib_strbuf.h - definitions for routines which use the common string buffers
*/
+#ifndef LIB_STRBUF_H
+#define LIB_STRBUF_H
#include <ntp_types.h>
+#include <ntp_malloc.h> /* for ZERO() */
/*
* Sizes of things
*/
-#define LIB_NUMBUFS 200
-#define LIB_BUFLENGTH 80
+#define LIB_NUMBUF 16
+#define LIB_BUFLENGTH 128
+
+typedef char libbufstr[LIB_BUFLENGTH];
+extern libbufstr lib_stringbuf[LIB_NUMBUF];
+extern int lib_nextbuf;
+extern int lib_inited;
+
/*
* Macro to get a pointer to the next buffer
*/
-#define LIB_GETBUF(buf) \
- do { \
- if (!lib_inited) \
- init_lib(); \
- buf = &lib_stringbuf[lib_nextbuf][0]; \
- if (++lib_nextbuf >= LIB_NUMBUFS) \
- lib_nextbuf = 0; \
- memset(buf, 0, LIB_BUFLENGTH); \
- } while (0)
+#define LIB_GETBUF(bufp) \
+ do { \
+ ZERO(lib_stringbuf[lib_nextbuf]); \
+ (bufp) = &lib_stringbuf[lib_nextbuf++][0]; \
+ lib_nextbuf %= COUNTOF(lib_stringbuf); \
+ } while (FALSE)
-extern char lib_stringbuf[LIB_NUMBUFS][LIB_BUFLENGTH];
-extern int lib_nextbuf;
-extern int lib_inited;
+#endif /* LIB_STRBUF_H */