home *** CD-ROM | disk | FTP | other *** search
- /*
- * lemalloc.c -- allocation routines useful to the whole lemming family
- *
- * copyright (c) by Alan W. Paeth, 1987. All rights reserved.
- */
-
- #include "lem.h"
-
- char *salloc(s)
- char *s;
- {
- char *out;
- out = (char*)(calloc(strlen(s)+1, sizeof(char)));
- strcpy(out, s);
- return(out);
- }
-
- objfree(i)
- {
- if (Otext)
- {
- free(Otext);
- Otext = 0;
- }
- free(o);
- o = 0;
- }
-
- objalloc(t)
- {
- int i;
- if (lastobj == MAXOBJS)
- {
- forobjects
- {
- if (Odel) break;
- }
- if (i == lastobj) err("out of object space");
- objfree(i);
- }
- else
- {
- i = lastobj++;
- o = (pel)(calloc(1, sizeof(el)));
- }
- Otext = 0;
- Otype = t;
- Otype = t;
- Oalign= galign;
- Oemph = gemph;
- Osize = gsize;
- return(i);
- }
-
- objcompress()
- {
- int i, j;
- forobjects
- {
- if (Onotdel) continue; /* look for a hole */
- for(j=i+1; j<lastobj; j++)
- {
- pel tmp;
- if (objs[j]->stat == DEL) continue; /* look for non-hole */
- tmp = objs[j];
- objs[j] = objs[i];
- objs[i] = tmp;
- break;
- }
- }
- forobjsrev
- {
- if (Odel) objfree(i);
- else break;
- }
- lastobj = i+1;
- }
-
- objnew(i)
- {
- Ostat = DEL;
- Ogroup = 0;
- objectop(i, DEL, UNDEL);
- }
-