home *** CD-ROM | disk | FTP | other *** search
- ////////////////
- // Heap Class //
- ////////////////
-
- #include <alloc.h>
-
- #include "sweep.h"
- #include "heap.hpp"
-
- //////////////////////
- // Initialize heap. //
- //////////////////////
-
- Heap::Heap (unsigned long s, unsigned b)
- {
- void far * base;
-
- if (~s) s = farcoreleft(); // check if use all available
- base = farmalloc (s); // allocate memory
-
- if (b) // if blocks specified
- oldheap = HeapInitBlk (base, s, b); // initialize with block count
- else
- oldheap = HeapInit (base, s); // initialize without block count
- }
-
- /////////////////////
- // Terminate heap. //
- /////////////////////
-
- Heap::~Heap()
- {
- farfree (HeapSelect (oldheap)); // deallocate and switch to previous
- }