2 * Copyright (C) 1995-2005, Index Data ApS
3 * See the file LICENSE for details.
5 * $Id: nmemsdup.c,v 1.5 2005-06-25 15:46:04 adam Exp $
10 * \brief Implements NMEM dup utilities
20 char *nmem_strdup (NMEM mem, const char *src)
22 char *dst = (char *)nmem_malloc (mem, strlen(src)+1);
27 char *nmem_strdupn (NMEM mem, const char *src, size_t n)
29 char *dst = (char *)nmem_malloc (mem, n+1);
35 int *nmem_intdup(NMEM mem, int v)
37 int *dst = (int*) nmem_malloc (mem, sizeof(int));
42 void nmem_strsplit_blank(NMEM nmem, const char *dstr, char ***darray, int *num)
44 nmem_strsplit(nmem, " ", dstr, darray, num);
47 void nmem_strsplit(NMEM nmem, const char *delim, const char *dstr,
48 char ***darray, int *num)
50 const char *cp = dstr;
51 for (*num = 0; *cp; (*num)++)
53 while (*cp && strchr(delim, *cp))
57 while (*cp && !strchr(delim, *cp))
65 *darray = nmem_malloc(nmem, *num * sizeof(**darray));
66 for (cp = dstr; *cp; )
69 while (*cp && strchr(delim, *cp))
74 while (*cp && !strchr(delim, *cp))
76 (*darray)[i++] = nmem_strdupn(nmem, cp0, cp - cp0);
84 * indent-tabs-mode: nil
86 * vim: shiftwidth=4 tabstop=8 expandtab