Added xstrndup (similar to strndup)
[yaz-moved-to-github.git] / include / yaz / xmalloc.h
index 290f23d..2c3ff9f 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2008 Index Data.
+ * Copyright (C) 1995-2009 Index Data.
  * All rights reserved.
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -24,7 +24,6 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/* $Id: xmalloc.h,v 1.9 2007-01-03 08:42:14 adam Exp $ */
 
 /**
  * \file xmalloc.h
@@ -45,6 +44,7 @@ YAZ_BEGIN_CDECL
 #define xcalloc(x,y) xcalloc_f(x,y, __FILE__, __LINE__)
 #define xfree(x) xfree_f(x, __FILE__, __LINE__)
 #define xstrdup(s) xstrdup_f(s, __FILE__, __LINE__)
+#define xstrndup(s, n) xstrndup_f(s, n, __FILE__, __LINE__)
 #define xmalloc_trav(s) xmalloc_trav_f(s, __FILE__, __LINE__)
     
 YAZ_EXPORT void *xrealloc_f (void *o, size_t size, const char *file, int line);
@@ -52,6 +52,8 @@ YAZ_EXPORT void *xmalloc_f (size_t size, const char *file, int line);
 YAZ_EXPORT void *xcalloc_f (size_t nmemb, size_t size,
                             const char *file, int line);
 YAZ_EXPORT char *xstrdup_f (const char *p, const char *file, int line);
+YAZ_EXPORT char *xstrndup_f(const char *p, size_t n,
+                            const char *file, int line);
 YAZ_EXPORT void xfree_f (void *p, const char *file, int line);
 YAZ_EXPORT void xmalloc_trav_f(const char *s, const char *file, int line);
 
@@ -61,6 +63,7 @@ YAZ_END_CDECL
 /*
  * Local variables:
  * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
  * indent-tabs-mode: nil
  * End:
  * vim: shiftwidth=4 tabstop=8 expandtab