5 #define ALIGNMENT 16 /* XXX: assuming that this alignment is enough */
6 #define SPACE 2048 /* must be multiple of ALIGNMENT */
8 typedef union { char irrelevant
[ALIGNMENT
]; double d
; } aligned
;
9 static aligned realspace
[SPACE
/ ALIGNMENT
];
10 #define space ((char *) realspace)
11 static unsigned int avail
= SPACE
; /* multiple of ALIGNMENT; 0<=avail<=SPACE */
13 /*@null@*//*@out@*/char *alloc(n
)
17 n
= ALIGNMENT
+ n
- (n
& (ALIGNMENT
- 1)); /* XXX: could overflow */
18 if (n
<= avail
) { avail
-= n
; return space
+ avail
; }
20 if (!x
) errno
= error_nomem
;
28 if (x
< space
+ SPACE
)
29 return; /* XXX: assuming that pointers are flat */