Bump copyright year
[yaz-moved-to-github.git] / test / tstnmem.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2010 Index Data
3  * See the file LICENSE for details.
4  */
5
6 #if HAVE_CONFIG_H
7 #include <config.h>
8 #endif
9
10 #include <errno.h>
11 #include <string.h>
12 #include <stdlib.h>
13 #include <ctype.h>
14
15 #include <yaz/nmem.h>
16 #include <yaz/test.h>
17
18 void tst(void)
19 {
20     NMEM n;
21     int j;
22     char *cp;
23
24     n = nmem_create();
25     YAZ_CHECK(n);
26
27     for (j = 1; j<500; j++)
28     {
29         cp = (char *) nmem_malloc(n, j);
30         YAZ_CHECK(cp);
31         if (sizeof(long) >= j)
32             *(long*) cp = 123L;
33 #if HAVE_LONG_LONG
34         if (sizeof(long long) >= j)
35             *(long long*) cp = 123L;
36 #endif
37         if (sizeof(double) >= j)
38             *(double*) cp = 12.2;
39     }
40     
41     for (j = 2000; j<20000; j+= 2000)
42     {
43         cp = (char *) nmem_malloc(n, j);
44         YAZ_CHECK(cp);
45     }
46     nmem_destroy(n);
47 }
48
49 int main (int argc, char **argv)
50 {
51     YAZ_CHECK_INIT(argc, argv);
52     tst();
53     YAZ_CHECK_TERM;
54 }
55 /*
56  * Local variables:
57  * c-basic-offset: 4
58  * c-file-style: "Stroustrup"
59  * indent-tabs-mode: nil
60  * End:
61  * vim: shiftwidth=4 tabstop=8 expandtab
62  */
63