home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Distributions / ucb / spencer_2bsd.tar.gz / 2bsd.tar / src / px / palloc.c < prev    next >
C/C++ Source or Header  |  1980-02-17  |  627b  |  45 lines

  1. /* (c) 1979 Regents of the University of California */
  2. #include "0x.h"
  3. #include "E.h"
  4.  
  5. extern char *sbrk(), *brk();
  6.  
  7. alloc(need)
  8.     char *need;
  9. {
  10.     register cnt, *wp;
  11.     register char *have;
  12.  
  13.     need = (need+1) &~ 1;
  14.     if ((have=high-memptr) < need) {
  15.         if (sbrk(need > have + 1024 ? need-have:1024) == -1)
  16.             error(EOUTOFMEM);
  17.         high = sbrk(0);
  18.     }
  19.     wp = memptr;
  20.     cnt = (need >> 1) & 077777;
  21.     do {
  22.         *wp++ = 0;
  23.     } while (--cnt);
  24.     wp = memptr;
  25.     memptr =+ need;
  26.     stklim();
  27.     return(wp);
  28. }
  29.  
  30. setmem()
  31. {
  32.     high = bottmem = memptr = sbrk(0);
  33.     stklim();
  34. }
  35.  
  36. free(cptr)
  37.     char *cptr;
  38. {
  39. }
  40.  
  41. stklim()
  42. {
  43.     maxstk = ((memptr + 07777) &~ 07777) + 512;
  44. }
  45.