home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V6 / usr / man / man3 / alloc.3 < prev    next >
Encoding:
Text File  |  1975-06-26  |  1015 b   |  48 lines

  1. .th ALLOC III 3/1/74
  2. .sh NAME
  3. alloc, free \*- core allocator
  4. .sh SYNOPSIS
  5. .ft B
  6. .nf
  7. char *alloc(size)
  8. .s3
  9. free(ptr)
  10. char *ptr;
  11. .fi
  12. .ft R
  13. .sh DESCRIPTION
  14. .it Alloc
  15. and
  16. .it free
  17. provide a simple general-purpose core management package.
  18. .it Alloc
  19. is given a size in bytes; it returns a pointer
  20. to an area at least that size which
  21. is even and hence can hold an object of any type.
  22. The argument to
  23. .it free
  24. is a pointer to an area previously allocated by
  25. .it alloc;
  26. this space is made available for further allocation.
  27. .s3
  28. Needless to say, grave disorder will result if the space
  29. assigned by
  30. .it alloc
  31. is overrun or if some random number is handed to
  32. .it free.
  33. .s3
  34. The routine uses a first-fit algorithm which
  35. coalesces blocks being freed with other
  36. blocks already free.
  37. It calls
  38. .it sbrk
  39. (see
  40. .it "break (II))"
  41. to get more core from the system when there is no
  42. suitable space already free.
  43. .sh DIAGNOSTICS
  44. Returns \*-1 if there is no available core.
  45. .sh BUGS
  46. Allocated memory contains garbage
  47. instead of being cleared.
  48.