Implementing Malloc (was Extended Memory without dereference operator)

Yossi Gil yogi at humus.Huji.AC.IL
Fri May 12 18:47:25 AEST 1989


In article <1143 at ptolemy.arc.nasa.gov> raymond at ptolemy.arc.nasa.gov.UUCP (Eric A
>It appears that I can write what I want in TC using the MK_FP macro to
>rewrite malloc (and perhaps free).  Anyone have any source/suggestions
>for doing this?
 K&R 2nd edition pp 185-189 have source code for malloc() and for free().
 Porting this code is easy (I could do it...).
>
>Is there anything I should know about extended memory?
>
You have to be in protected mode for using it, and if you are there are alot
of problems in using normal DOS/BIOS services. I think that the standard
pointer approach would'nt help. It seems that the 'handle' approach for
accessing data is better. The basic idea is that a handle is pointer
to a pointer to data. You can access ther data by doing something like:

 Pointer = GetPointer(handle)
 Pointer[i] = ...
 .....
The catch is that the pointer is valid only until the next call
to GetPointer() with any other handle. Programming in this style
is not easy, but then the GetPointer() function can be very strong,
it can adapt itself to the hardware, caching into near, far, expanded,
extended, unknown memory, and even using the disk.



More information about the Comp.lang.c mailing list