summaryrefslogtreecommitdiff
path: root/lib/string.h
diff options
context:
space:
mode:
authorPavel Tvrdik <pawel.tvrdik@gmail.com>2016-11-16 12:10:34 +0100
committerPavel Tvrdik <pawel.tvrdik@gmail.com>2016-11-16 12:22:01 +0100
commitbb721f0d6d00bc2d7944640bfaf1cb266060d972 (patch)
tree3444bcd1bbaebcf22b8a861b7933ffae98b3bb19 /lib/string.h
parent3ec0bedc6077ebd2716f29c68155bab806aaa8d6 (diff)
Add lp_strdup function for string duplication on linpool
Diffstat (limited to 'lib/string.h')
-rw-r--r--lib/string.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/string.h b/lib/string.h
index 75cb88dd..0d34f9c5 100644
--- a/lib/string.h
+++ b/lib/string.h
@@ -13,6 +13,8 @@
#include <string.h>
#include <strings.h>
+#include "lib/resource.h"
+
int bsprintf(char *str, const char *fmt, ...);
int bvsprintf(char *str, const char *fmt, va_list args);
int bsnprintf(char *str, int size, const char *fmt, ...);
@@ -39,6 +41,15 @@ xstrdup(const char *c)
return z;
}
+static inline char *
+lp_strdup(linpool *lp, const char *c)
+{
+ size_t l = strlen(c) + 1;
+ char *z = lp_allocu(lp, l);
+ memcpy(z, c, l);
+ return z;
+}
+
static inline void
memset32(void *D, u32 val, uint n)
{