diff options
| author | Gleb Smirnoff <glebius@FreeBSD.org> | 2015-10-21 19:06:51 +0000 |
|---|---|---|
| committer | Gleb Smirnoff <glebius@FreeBSD.org> | 2015-10-21 19:06:51 +0000 |
| commit | f71544a98e2e3df8f536fa75158348666ed2da91 (patch) | |
| tree | 77f416a57107dc94a8d526dd0075a29e82a25bba /include/lib_strbuf.h | |
Notes
Diffstat (limited to 'include/lib_strbuf.h')
| -rw-r--r-- | include/lib_strbuf.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/include/lib_strbuf.h b/include/lib_strbuf.h new file mode 100644 index 0000000000000..5ee92d6f83417 --- /dev/null +++ b/include/lib_strbuf.h @@ -0,0 +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_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(bufp) \ + do { \ + ZERO(lib_stringbuf[lib_nextbuf]); \ + (bufp) = &lib_stringbuf[lib_nextbuf++][0]; \ + lib_nextbuf %= COUNTOF(lib_stringbuf); \ + } while (FALSE) + +#endif /* LIB_STRBUF_H */ |
