]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Add lp_strdup function for string duplication on linpool
authorPavel Tvrdik <pawel.tvrdik@gmail.com>
Wed, 16 Nov 2016 11:10:34 +0000 (12:10 +0100)
committerPavel Tvrdik <pawel.tvrdik@gmail.com>
Wed, 16 Nov 2016 11:22:01 +0000 (12:22 +0100)
lib/string.h

index 75cb88ddc82e0c1dddbc579c8adc06dc2b25bf37..0d34f9c5769aa2b6c1bcd5c67f91048af8f64ee0 100644 (file)
@@ -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)
 {