Bump year
[yaz-moved-to-github.git] / test / tstnmem.c
1 /*
2  * Copyright (C) 1995-2005, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: tstnmem.c,v 1.4 2005-01-15 19:47:15 adam Exp $
6  */
7
8 #if HAVE_CONFIG_H
9 #include <config.h>
10 #endif
11
12 #include <errno.h>
13 #include <string.h>
14 #include <stdlib.h>
15 #include <ctype.h>
16
17 #include <yaz/nmem.h>
18
19 int main (int argc, char **argv)
20 {
21     void *cp;
22     NMEM n;
23     int j;
24
25     nmem_init();
26     n = nmem_create();
27     if (!n)
28         exit (1);
29     for (j = 1; j<500; j++)
30     {
31         cp = nmem_malloc(n, j);
32         if (!cp)
33             exit(2);
34         if (sizeof(long) >= j)
35             *(long*) cp = 123L;
36 #if HAVE_LONG_LONG
37         if (sizeof(long long) >= j)
38             *(long long*) cp = 123L;
39 #endif
40         if (sizeof(double) >= j)
41             *(double*) cp = 12.2;
42     }
43     
44     for (j = 2000; j<20000; j+= 2000)
45     {
46         cp = nmem_malloc(n, j);
47         if (!cp)
48             exit(3);
49     }
50     nmem_destroy(n);
51     nmem_exit();
52     exit(0);
53 }