Bump year
[yaz-moved-to-github.git] / src / nmemsdup.c
1 /*
2  * Copyright (C) 1995-2005, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: nmemsdup.c,v 1.3 2005-01-15 19:47:14 adam Exp $
6  */
7
8 /**
9  * \file nmemsdup.c
10  * \brief Implements NMEM dup utilities
11  */
12
13 #if HAVE_CONFIG_H
14 #include <config.h>
15 #endif
16
17 #include <string.h>
18 #include <yaz/nmem.h>
19
20 char *nmem_strdup (NMEM mem, const char *src)
21 {
22     char *dst = (char *)nmem_malloc (mem, strlen(src)+1);
23     strcpy (dst, src);
24     return dst;
25 }
26
27 char *nmem_strdupn (NMEM mem, const char *src, size_t n)
28 {
29     char *dst = (char *)nmem_malloc (mem, n+1);
30     memcpy (dst, src, n);
31     dst[n] = '\0';
32     return dst;
33 }
34
35 int *nmem_intdup(NMEM mem, int v)
36 {
37     int *dst = (int*) nmem_malloc (mem, sizeof(int));
38     *dst = v;
39     return dst;
40 }