Bump copyright year
[yaz-moved-to-github.git] / test / tstnmem.c
index 54048c8..7267744 100644 (file)
@@ -1,8 +1,6 @@
-/*
- * Copyright (c) 2002-2004, Index Data
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2010 Index Data
  * See the file LICENSE for details.
- *
- * $Id: tstnmem.c,v 1.2 2004-09-29 20:15:48 adam Exp $
  */
 
 #if HAVE_CONFIG_H
 #include <ctype.h>
 
 #include <yaz/nmem.h>
+#include <yaz/test.h>
 
-int main (int argc, char **argv)
+void tst(void)
 {
-    void *cp;
     NMEM n;
     int j;
+    char *cp;
 
-    nmem_init();
     n = nmem_create();
-    if (!n)
-        exit (1);
+    YAZ_CHECK(n);
+
     for (j = 1; j<500; j++)
     {
-        cp = nmem_malloc(n, j);
-        if (!cp)
-            exit(2);
+        cp = (char *) nmem_malloc(n, j);
+        YAZ_CHECK(cp);
+        if (sizeof(long) >= j)
+            *(long*) cp = 123L;
+#if HAVE_LONG_LONG
+        if (sizeof(long long) >= j)
+            *(long long*) cp = 123L;
+#endif
+        if (sizeof(double) >= j)
+            *(double*) cp = 12.2;
     }
     
     for (j = 2000; j<20000; j+= 2000)
     {
-        cp = nmem_malloc(n, j);
-        if (!cp)
-            exit(3);
+        cp = (char *) nmem_malloc(n, j);
+        YAZ_CHECK(cp);
     }
     nmem_destroy(n);
-    nmem_exit();
-    exit(0);
 }
+
+int main (int argc, char **argv)
+{
+    YAZ_CHECK_INIT(argc, argv);
+    tst();
+    YAZ_CHECK_TERM;
+}
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+