Since it's possible to use libc's MM via cmem unit, would the opposite be possible?
Mailing lists / fpc-pascal / 2008-12
Using FPC MM in a C program
7 messages · 5 people · –
- Lleledumbo 2
- MMichael Van Canneyt 2
- KKrishna 1
- MMicha Nelissen 1
- VVinzent Höfler 1
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
leledumbo wrote 5 lines
The C library, this is another matter. I am not sure that it supports plugging in a memory manager.
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.
Michael.
Michael Van Canneyt wrote 11 lines
I suppose overriding malloc is enough. I regularly use a non-system memory manager (malloc) even on Windows. btw, has anyone tried jemalloc (used by firefox) with freepascal programs?
Cheers,
-Krishna
The C library, this is another matter. I am not sure that it supports plugging in a…
What if I replace libc's MM code with FPC one? Is it permitted?
The C library, this is another matter. I am not sure that it supports plugging in a…
Michael Van Canneyt wrote 9 lines
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.
Vinzent.
Vinzent Höfler wrote 22 lines
Yes and no;
Sometimes macros are used to 'redirect' malloc() and free() in existing code to the custom routines. It depends on the library.
Michael.
Since it's possible to use libc's MM via cmem unit, would the opposite be possible? View…
leledumbo wroteSince it's possible to use libc's MM via cmem unit, would the opposite be possible?
I have a "crtl.pas" which defines a few functions (malloc, calloc, free, memmove, memcpy) to help in using libraries written in C with fpc programs without needing external dependencies (msvcrt.dll on windows, for some reason that did not work for me).
However, it's a all-or-nothing situation. A program uses either this crtl unit, or it links a C library like msvcrt.dll or something similar; using both is asking for trouble.
Micha
