[comp.lang.c] Implementing Malloc

raymond@ptolemy.arc.nasa.gov (Eric A. Raymond) (05/09/89)

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?  The source needn't be the original malloc.  Just some
version for Messy-DOS.

Is there anything I should know about extended memory?





-- 
Eric A. Raymond  (raymond@ptolemy.arc.nasa.gov)
G7 C7 G7 G#7 G7 G+13 C7 GM7 Am7 Bm7 Bd7 Am7 C7 Do13 G7 C7 G7 D+13: Elmore James

yogi@humus.Huji.AC.IL (Yossi Gil) (05/12/89)

In article <1143@ptolemy.arc.nasa.gov> raymond@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.