malloc question

Miller Abel miller.abel at solopoint.com
Thu Feb 26 14:22:32 PST 1998


If Kaffe itself doesn't use the libc.a version of malloc/free, you can
write yourself an "interlude":

#undef malloc
#undef free

void * malloc( size_t a )
{
    gc_malloc(a, &gc_fixed);
}

Then the same for free().

Link this object with your program before searching the libraries and
all references within your objects and those of the libraries you link
with should find your version of malloc/free. No recompilation
necessary. Note that any code you can recompile, you should recompile to
avoid the overhead of the interludes.

One possible twist is that these other libraries may rely on other
incompatible memory allocation systems which interfere with gc_...
routines' use of the heap. But, one step at a time!

Hope this helps.
-- Miller

> ----------
> From: 	e. lambrecht
> Sent: 	Thursday, February 26, 1998 11:39 AM
> To: 	tullmann at cs.utah.edu; kaffe at kaffe.org
> Subject: 	Re: malloc question 
> 
> > As to the original poster's questions, I suggest setting things up
> so
> > that your Java objects associated with ImageMagick objects contain
> > pointer to the image data, then you can just rely on the garbage
> > collector and can simply get rid of all free()'s.  For the I/O
> related
> > allocations, you should re-direct those operations through the
> > threaded IO calls anyway ---see kaffe/kaffevm/threadCalls.h.
> 
> This seems to point me in the direction of recompiling ImageMagick
> with adjustments to its header files so that it makes use of the kaffe
> file and memory routines. However, ImageMagick also refers to libpng,
> libjpeg, libX11, and others, which makes me think I'll have to
> recompile those with the new header files as well (they surely use
> malloc and file routines as well).
> 
> Is there some way I could just exclude the normal 'malloc' and IO
> code, and instead link my code to a kaffe C library rather than the
> normal C library?
> 
> Thanks for your help.
> 
> Eric...
> 
> 



More information about the kaffe mailing list