X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fmempool-str.c;h=1072e3dacb7fde29a0deceef692d77732478b6fa;hb=b8667492cf36a609939ee35ac42900ff0b0cc80f;hp=cb2466304a902147f7be3b52fd028257ba06a2d1;hpb=5f81280e4ec7a5517e94f1c1f53e42fba537fbd8;p=libucw.git diff --git a/ucw/mempool-str.c b/ucw/mempool-str.c index cb246630..1072e3da 100644 --- a/ucw/mempool-str.c +++ b/ucw/mempool-str.c @@ -7,8 +7,8 @@ * of the GNU Lesser General Public License. */ -#include "ucw/lib.h" -#include "ucw/mempool.h" +#include +#include #include #include @@ -18,14 +18,14 @@ mp_strdup(struct mempool *p, const char *s) { if (!s) return NULL; - uns l = strlen(s) + 1; + size_t l = strlen(s) + 1; char *t = mp_alloc_fast_noalign(p, l); memcpy(t, s, l); return t; } void * -mp_memdup(struct mempool *p, const void *s, uns len) +mp_memdup(struct mempool *p, const void *s, size_t len) { void *t = mp_alloc_fast(p, len); memcpy(t, s, len); @@ -38,12 +38,12 @@ mp_multicat(struct mempool *p, ...) va_list args, a; va_start(args, p); char *x, *y; - uns cnt = 0; + uint cnt = 0; va_copy(a, args); while (x = va_arg(a, char *)) cnt++; - uns *sizes = alloca(cnt * sizeof(uns)); - uns len = 1; + size_t *sizes = alloca(cnt * sizeof(*sizes)); + size_t len = 1; cnt = 0; va_end(a); va_copy(a, args); @@ -64,17 +64,17 @@ mp_multicat(struct mempool *p, ...) } char * -mp_strjoin(struct mempool *p, char **a, uns n, uns sep) +mp_strjoin(struct mempool *p, char **a, uint n, uint sep) { - uns sizes[n]; - uns len = 1; - for (uns i=0; i @@ -98,6 +107,7 @@ int main(void) char *a[] = { "bugs", "gnats", "insects" }; puts(mp_strjoin(p, a, 3, '.')); puts(mp_strjoin(p, a, 3, 0)); + puts(mp_str_from_mem(p, s+1, 2)); return 0; }