[fpc-pascal] Using FPC MM in a C program

Michael Van Canneyt michael at freepascal.org
Wed Dec 31 13:17:09 CET 2008

On Wed, 31 Dec 2008, Vinzent Höfler wrote:

> Michael Van Canneyt wrote:
> > 
> > On Wed, 31 Dec 2008, leledumbo wrote:
> > 
> > > Since it's possible to use libc's MM via cmem unit, would the opposite be
> > > possible?
> > 
> > > >From the point of view of FPC, there should not be a big problem.
> > The C library, this is another matter. I am not sure that it
> > supports plugging in a memory manager.
> Well, if you manage to exchange the standard memory-related subroutines (i.e.
> malloc() & Co.) from the C-library with your own subroutines, it shouldn't be
> a problem. But I don't know if that's possible if libc is included in the
> project. Technically it should if you can convince the linker of doing so. ;)
> > There are many libraries which require you to provide memory managing
> > routines.
> > But as far as I know, this is all done using some macros.
> No, last time I looked, at least in the case of the libpng this is done via
> real subroutines.

Yes and no; 
Sometimes macros are used to 'redirect' malloc() and free() in existing
code to the custom routines. It depends on the library.


More information about the fpc-pascal mailing list