Merge branch 'vendor/OPENSSH'
[dragonfly.git] / gnu / lib / libregex / test / malloc-test.c
1 /* $DragonFly: src/gnu/lib/libregex/test/malloc-test.c,v 1.2 2008/06/05 18:01:49 swildner Exp $ */
2
3 typedef struct {
4    unsigned *bits;
5    unsigned size;
6 } bits_list_type;
7
8 #define BYTEWIDTH  8
9
10 #define BITS_BLOCK_SIZE (sizeof (unsigned) * BYTEWIDTH)
11 #define BITS_BLOCK(position) ((position) / BITS_BLOCK_SIZE)
12 #define BITS_MASK(position) (1 << ((position) % BITS_BLOCK_SIZE))
13
14 static unsigned
15 init_bits_list (bits_list_ptr)
16   bits_list_type *bits_list_ptr;
17 {
18   bits_list_ptr->bits = NULL;
19   bits_list_ptr->bits = (unsigned *) malloc (sizeof (unsigned));
20
21   if (bits_list_ptr->bits == NULL)
22     return 0;
23
24   bits_list_ptr->bits[0] = (unsigned)0;
25   bits_list_ptr->size = BITS_BLOCK_SIZE;
26
27   return 1;
28 }
29
30
31 main()
32 {
33   bits_list_type dummy;
34   bits_list_type dummy_1;
35   bits_list_type dummy_2;
36   bits_list_type dummy_3;
37
38   init_bits_list (&dummy);
39 printf("init 1\n");
40   init_bits_list (&dummy_1);
41 printf("init 2\n");
42   init_bits_list (&dummy_2);
43 printf("init 3\n");
44   init_bits_list (&dummy_3);
45 printf("init 4\n");
46 }