diff options
Diffstat (limited to 'lib/string.h')
-rw-r--r-- | lib/string.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/string.h b/lib/string.h index 9af49b9e..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, ...); @@ -30,6 +32,34 @@ static inline char *xbasename(const char *str) return s ? s+1 : (char *) str; } +static inline char * +xstrdup(const char *c) +{ + size_t l = strlen(c) + 1; + char *z = xmalloc(l); + memcpy(z, c, l); + 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) +{ + u32 *dst = D; + uint i; + + for (i = 0; i < n; i++) + dst[i] = val; +} + #define ROUTER_ID_64_LENGTH 23 #endif |