Source restructure. yaz-marcdump part of installation
[yaz-moved-to-github.git] / src / nmemsdup.c
1 /*
2  * Copyright (c) 1997-2003, Index Data.
3  * See the file LICENSE for details.
4  *
5  * $Id: nmemsdup.c,v 1.1 2003-10-27 12:21:33 adam Exp $
6  */
7 #if HAVE_CONFIG_H
8 #include <config.h>
9 #endif
10
11 #include <string.h>
12 #include <yaz/nmem.h>
13
14 char *nmem_strdup (NMEM mem, const char *src)
15 {
16     char *dst = (char *)nmem_malloc (mem, strlen(src)+1);
17     strcpy (dst, src);
18     return dst;
19 }
20
21 char *nmem_strdupn (NMEM mem, const char *src, size_t n)
22 {
23     char *dst = (char *)nmem_malloc (mem, n+1);
24     memcpy (dst, src, n);
25     dst[n] = '\0';
26     return dst;
27 }
28
29 int *nmem_intdup(NMEM mem, int v)
30 {
31     int *dst = (int*) nmem_malloc (mem, sizeof(int));
32     *dst = v;
33     return dst;
34 }