00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 extern _sav();
00022 extern _rst();
00023
00024 #define assert(x)
00025 #define UNDEF 0x8000
00026
00027 struct adm {
00028 struct adm *next;
00029 int size;
00030 };
00031
00032 struct adm *_lastp = 0;
00033 struct adm *_highp = 0;
00034
00035 _new(n,pp) int n; struct adm **pp; {
00036 struct adm *p,*q;
00037 int *ptmp;
00038
00039 n = ((n+sizeof(*p)-1) / sizeof(*p)) * sizeof(*p);
00040 if ((p = _lastp) != 0)
00041 do {
00042 q = p->next;
00043 if (q->size >= n) {
00044 assert(q->size%sizeof(adm) == 0);
00045 if ((q->size -= n) == 0) {
00046 if (p == q)
00047 p = 0;
00048 else
00049 p->next = q->next;
00050 if (q == _highp)
00051 _highp = p;
00052 }
00053 _lastp = p;
00054 p = (struct adm *)((char *)q + q->size);
00055 q = (struct adm *)((char *)p + n);
00056 goto initialize;
00057 }
00058 p = q;
00059 } while (p != _lastp);
00060
00061 _sav(&p);
00062 q = (struct adm *)((char *)p + n);
00063 _rst(&q);
00064 initialize:
00065 *pp = p;
00066 ptmp = (int *)p;
00067 while (ptmp < (int *)q)
00068 *ptmp++ = UNDEF;
00069 }