diff options
| author | manuel <manuel@mausz.at> | 2013-02-04 00:08:53 +0100 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2013-02-04 00:08:53 +0100 |
| commit | 69aec538b456402170dc723af417ba5c05389c32 (patch) | |
| tree | e6f34c543f17c6392447ea337b2e2868212424d1 /gen_allocdefs.h | |
| download | qmail-69aec538b456402170dc723af417ba5c05389c32.tar.gz qmail-69aec538b456402170dc723af417ba5c05389c32.tar.bz2 qmail-69aec538b456402170dc723af417ba5c05389c32.zip | |
qmail 1.03 import
Diffstat (limited to 'gen_allocdefs.h')
| -rw-r--r-- | gen_allocdefs.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gen_allocdefs.h b/gen_allocdefs.h new file mode 100644 index 0000000..783a9b1 --- /dev/null +++ b/gen_allocdefs.h | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | #ifndef GEN_ALLOC_DEFS_H | ||
| 2 | #define GEN_ALLOC_DEFS_H | ||
| 3 | |||
| 4 | #define GEN_ALLOC_ready(ta,type,field,len,a,i,n,x,base,ta_ready) \ | ||
| 5 | int ta_ready(x,n) register ta *x; register unsigned int n; \ | ||
| 6 | { register unsigned int i; \ | ||
| 7 | if (x->field) { \ | ||
| 8 | i = x->a; \ | ||
| 9 | if (n > i) { \ | ||
| 10 | x->a = base + n + (n >> 3); \ | ||
| 11 | if (alloc_re(&x->field,i * sizeof(type),x->a * sizeof(type))) return 1; \ | ||
| 12 | x->a = i; return 0; } \ | ||
| 13 | return 1; } \ | ||
| 14 | x->len = 0; \ | ||
| 15 | return !!(x->field = (type *) alloc((x->a = n) * sizeof(type))); } | ||
| 16 | |||
| 17 | #define GEN_ALLOC_readyplus(ta,type,field,len,a,i,n,x,base,ta_rplus) \ | ||
| 18 | int ta_rplus(x,n) register ta *x; register unsigned int n; \ | ||
| 19 | { register unsigned int i; \ | ||
| 20 | if (x->field) { \ | ||
| 21 | i = x->a; n += x->len; \ | ||
| 22 | if (n > i) { \ | ||
| 23 | x->a = base + n + (n >> 3); \ | ||
| 24 | if (alloc_re(&x->field,i * sizeof(type),x->a * sizeof(type))) return 1; \ | ||
| 25 | x->a = i; return 0; } \ | ||
| 26 | return 1; } \ | ||
| 27 | x->len = 0; \ | ||
| 28 | return !!(x->field = (type *) alloc((x->a = n) * sizeof(type))); } | ||
| 29 | |||
| 30 | #define GEN_ALLOC_append(ta,type,field,len,a,i,n,x,base,ta_rplus,ta_append) \ | ||
| 31 | int ta_append(x,i) register ta *x; register type *i; \ | ||
| 32 | { if (!ta_rplus(x,1)) return 0; x->field[x->len++] = *i; return 1; } | ||
| 33 | |||
| 34 | #endif | ||
