This is the mail archive of the
java-discuss@sources.redhat.com
mailing list for the Java project.
Re: alloca and native code
- To: Oskar Liljeblad <osk at hem dot passagen dot se>
- Subject: Re: alloca and native code
- From: Jeff Sturm <jeff dot sturm at appnet dot com>
- Date: Tue, 12 Sep 2000 10:05:55 -0400
- CC: java-discuss at sourceware dot cygnus dot com
- Organization: AppNet Inc.
- References: <20000912123132.A27966@strix.eductussyd.se>
Oskar Liljeblad wrote:
> Is it ok to use alloca from native code?
I think so. There may be some portability issues; i.e. some OSes need alloca.h,
some don't have it:
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
> I want to allocate a piece
> of memory which isn't scanned or collected by the GC, which is freed
> when the (native implementation of the) method returns.
Memory reserved with alloca() _will_ be scanned by boehm-gc, like the rest of
the stack. To avoid that, you could allocate memory with _Jv_AllocBytes
instead. I don't remember if that function is exported, however.
--
Jeff Sturm
jeff.sturm@appnet.com