This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: problem when mapping malloc to GC_malloc.
- From: Christian Nolte <ch dot nolte at noltec dot org>
- To: abhishek desai <abhi00 at gmail dot com>
- Cc: java at gcc dot gnu dot org
- Date: Thu, 18 Jun 2009 17:14:02 +0200
- Subject: Re: problem when mapping malloc to GC_malloc.
- References: <898285d30906180800q3b5bd3b2h1d4a11d6a8245e34@mail.gmail.com>
-----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-----