problem when mapping malloc to GC_malloc.
Christian Nolte
ch.nolte@noltec.org
Thu Jun 18 15:14:00 GMT 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Abhishek,
abhishek desai wrote:
> My JNI code includes redefinitions to the malloc, free and realloc
> functions (shown below). These functions call GC_malloc, GC_free and
> GC_realloc respectively. This is done so that any calls to the malloc
> get allocated through the garbage collector.
I presume you are using Hans Boehm's garbage collector? If so, did you
follow the instructions on:
http://www.hpl.hp.com/personal/Hans_Boehm/gc/simple_example.html
What platform are you developing for? If it is not Linux, you have to
make sure that GC_INIT() is being called before using any of the GC_xxx
functions.
> However this is failing
> with segfault. Any clues why this does not work ?
> I am using this code along with the libgcj library linked dynamically
> with my application.
>
> void *malloc(size_t size)
> {
> return GC_malloc(size);
> }
>
> void *realloc(void *ptr, size_t size)
> {
> return GC_realloc(ptr, size);
> }
>
> void free(void *ptr)
> {
> GC_free(ptr);
> }
Perhaps you can give us some more context. A simple, compilable example
would be great to see where and how exactly you are using your
redefinitions.
Best regards,
Christian
- --
"He's an unconventional pirate paramedic with a mysterious suitcase
handcuffed to his arm. She's a pregnant gypsy widow from aristocratic
European stock. They fight crime!"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iEYEARECAAYFAko6WboACgkQCNjA0nfhW7xDYwCgpI3ntEEScbqbQOpCkfi1Z3KG
lrQAoI8+xh/swyVSgREAMmjX1B8rIWFl
=A/lO
-----END PGP SIGNATURE-----
More information about the Java
mailing list