]> andersk Git - splint.git/blame - test/db1/eref.c
Added support for ISO C99 _Bool and stdbool bool/true/false. The
[splint.git] / test / db1 / eref.c
CommitLineData
885824d3 1# include <stdio.h>
2# include <stdlib.h>
3# include "eref.h"
4
5eref_ERP eref_Pool; /* private */
6static bool needsInit = TRUE; /* private */
7
8eref eref_alloc (void)
9{
10 int i, res;
11
12 for (i=0; (eref_Pool.status[i] == used) && (i < eref_Pool.size); i++);
13
14 res = i;
15
16 if (res == eref_Pool.size)
17 {
18 eref_Pool.conts =
19 (employee *) realloc (eref_Pool.conts,
20 2 * eref_Pool.size * sizeof (employee));
21
22 if (eref_Pool.conts == 0)
23 {
24 printf ("Malloc returned null in eref_alloc\n");
25 exit (1);
26 }
27
28 eref_Pool.status =
29 (eref_status *) realloc (eref_Pool.status,
30 2 * eref_Pool.size * sizeof (eref_status));
31
32 if (eref_Pool.status == 0)
33 {
34 printf ("Malloc returned null in eref_alloc\n");
35 exit (1);
36 }
37
38 eref_Pool.size = 2*eref_Pool.size;
39
40 for (i = res+1; i < eref_Pool.size; i++)
41 eref_Pool.status[i] = avail;
42 }
43
44 eref_Pool.status[res] = used;
45 return (eref) res;
46}
47
48void eref_initMod (void)
49{
50 int i;
51 const int size = 16;
52
0bd4c301 53 if (needsInit == false) /* will produce a warning if FALSE is used instead */
885824d3 54 {
55 return;
56 }
57
58 needsInit = FALSE;
59 bool_initMod ();
60 employee_initMod ();
61
62 eref_Pool.conts = (employee *) malloc (size * sizeof (employee));
63
64 if (eref_Pool.conts == 0)
65 {
66 printf ("Malloc returned null in eref_initMod\n");
67 exit (1);
68 }
69
70 eref_Pool.status = (eref_status *) malloc (size * sizeof (eref_status));
71
72 if (eref_Pool.status == 0)
73 {
74 printf ("Malloc returned null in eref_initMod\n");
75 exit (1);
76 }
77
78 eref_Pool.size = size;
79
80 for (i = 0; i < size; i++)
81 {
82 eref_Pool.status[i] = avail;
83 }
84}
85
86
87
This page took 0.068588 seconds and 5 git commands to generate.