]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Lib: added tmp_v?sprintf and tmp_strdup allocating from tmp_linpool
authorMaria Matejka <mq@ucw.cz>
Wed, 2 Oct 2024 20:32:07 +0000 (22:32 +0200)
committerMaria Matejka <mq@ucw.cz>
Fri, 14 Mar 2025 19:44:10 +0000 (20:44 +0100)
lib/string.h

index 8831666c7d73bc158dca08b161e1a72da30cf47f..7e04919510c1b935cb61ff0345ae243cf2d6659e 100644 (file)
@@ -27,6 +27,9 @@ char *lp_vsprintf(linpool *p, const char *fmt, va_list args);
 #define tmp_sprintf(...)    lp_sprintf(tmp_linpool, __VA_ARGS__)
 #define tmp_vsprintf(...)   lp_vsprintf(tmp_linpool, __VA_ARGS__)
 
+#define tmp_sprintf(...)  lp_sprintf(tmp_linpool, __VA_ARGS__)
+#define tmp_vsprintf(...)  lp_vsprintf(tmp_linpool, __VA_ARGS__)
+
 int buffer_vprint(buffer *buf, const char *fmt, va_list args);
 int buffer_print(buffer *buf, const char *fmt, ...);
 void buffer_puts(buffer *buf, const char *str);
@@ -66,6 +69,17 @@ lp_strdup(linpool *lp, const char *c)
   return z;
 }
 
+#define tmp_strdup(x) lp_strdup(tmp_linpool, (x))
+
+static inline char *
+mb_strdup(pool *p, const char *c)
+{
+  size_t l = strlen(c) + 1;
+  char *z = mb_alloc(p, l);
+  memcpy(z, c, l);
+  return z;
+}
+
 static inline void
 memset32(void *D, u32 val, uint n)
 {