From: Pavel Tvrdik Date: Wed, 16 Nov 2016 11:10:34 +0000 (+0100) Subject: Add lp_strdup function for string duplication on linpool X-Git-Tag: v2.0.0-pre0~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb721f0d6d00bc2d7944640bfaf1cb266060d972;p=thirdparty%2Fbird.git Add lp_strdup function for string duplication on linpool --- diff --git a/lib/string.h b/lib/string.h index 75cb88ddc..0d34f9c57 100644 --- a/lib/string.h +++ b/lib/string.h @@ -13,6 +13,8 @@ #include #include +#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) {