X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fnmemsdup.c;h=33a643eabe10d483c9d70d98bd5b2cd061b52400;hb=c39a893dfdae5f792139177132e7e7a70e010aa7;hp=d33caf9c6bf7ea88ca021590308cdb6c23d49a39;hpb=d9ee01635f03f9095a66f71b73580560d48798e8;p=yaz-moved-to-github.git diff --git a/util/nmemsdup.c b/util/nmemsdup.c index d33caf9..33a643e 100644 --- a/util/nmemsdup.c +++ b/util/nmemsdup.c @@ -1,19 +1,12 @@ /* - * Copyright (c) 1997, Index Data. + * Copyright (c) 1997-2003, Index Data. * See the file LICENSE for details. - * Sebastian Hammer, Adam Dickmeiss - * - * $Log: nmemsdup.c,v $ - * Revision 1.3 1999-11-30 13:47:12 adam - * Improved installation. Moved header files to include/yaz. - * - * Revision 1.2 1998/02/11 11:53:36 adam - * Changed code so that it compiles as C++. - * - * Revision 1.1 1997/09/17 12:10:42 adam - * YAZ version 1.4. * + * $Id: nmemsdup.c,v 1.6 2003-03-18 13:34:37 adam Exp $ */ +#if HAVE_CONFIG_H +#include +#endif #include #include @@ -24,3 +17,18 @@ char *nmem_strdup (NMEM mem, const char *src) strcpy (dst, src); return dst; } + +char *nmem_strdupn (NMEM mem, const char *src, size_t n) +{ + char *dst = (char *)nmem_malloc (mem, n+1); + memcpy (dst, src, n); + dst[n] = '\0'; + return dst; +} + +int *nmem_intdup(NMEM mem, int v) +{ + int *dst = (int*) nmem_malloc (mem, sizeof(int)); + *dst = v; + return dst; +}