Dec 192017
Implements a based heap out of a Windows GlobalAlloc() buffer.
File SEGHEAP.ZIP from The Programmer’s Corner in
Category C Source Code
Implements a based heap out of a Windows GlobalAlloc() buffer.
File Name File Size Zip Size Zip Type
SEGHEAP.C 8265 2044 deflated
SEGHEAP.DOC 1555 804 deflated
SEGHEAP.H 563 250 deflated

Download File SEGHEAP.ZIP Here

Contents of the SEGHEAP.DOC file


by Stephen Chung ([email protected])


These routines are to be used with Microsoft Windows 3.0. The library
implements a segmented heap in global memory space, allocating and freeing
memory blocks of different sizes at the user's request. It solves the
typical Windows problem of not being able to efficiently handle a large
number of small memory blocks allocated globally.


These routines lock a memory handle immediately after allocation. As
a result, they work with PROTECTED MODE ONLY.

I think these routines are OK, but let me know if you find a bug.

How to use

The routines SegHeapAlloc, SegHeapFree and SegHeapRealloc basically
parallel the malloc, free and realloc functions found in standard C
libraries. FreeAllMemory is designed to be used by the end of a program,
when all dynamic memory can be released. MemoryStatistics will
calculate some memory usage statistics.


Theoretically, you are required to obtain special approval from me (because
I copyrighted these routines) if you want to use them in your programs.
However, I usually don't really care if you are not using these routines in
a commercial, shareware etc. product.

Any questions and/or bug fixes, please send email to:

Stephen Chung [email protected]

If it bounces, then try [email protected]

Have fun!

 December 19, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>