Included xmalloc.h from log.h, if usingthe old system, as it used to be
[yaz-moved-to-github.git] / test / tstnmem.c
1 /*
2  * Copyright (c) 2002-2004, Index Data
3  * See the file LICENSE for details.
4  *
5  * $Id: tstnmem.c,v 1.2 2004-09-29 20:15:48 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     }
35     
36     for (j = 2000; j<20000; j+= 2000)
37     {
38         cp = nmem_malloc(n, j);
39         if (!cp)
40             exit(3);
41     }
42     nmem_destroy(n);
43     nmem_exit();
44     exit(0);
45 }