Patch for Review: JvGetStringUTF and JvTempCString

Andrew Haley aph@redhat.com
Tue Aug 12 15:34:00 GMT 2003


Mohan Embar writes:
 > >>I totally agree that we have a problem here, I just wonder if this is 
 > >>the right solution. Two things that would make me like this better:
 > >>
 > >>1. Can it be made to allocate only the space that it needs on the 
 > >>stack?
 > >
 > >How? (The only way I can think of doing this in one line is with a macro.)
 > 
 > #define JV_TEMP_UTF_STRING(jstr, buf) \
 >   char* buf = __builtin_alloca (JvGetStringUTFLength (jstr) + 1); \

char[JvGetStringUTFLength (jstr) + 1] buf;

 >   JvGetStringUTFChars(jstr, buf);
 > 
 > Not sure how I feel about this.

It depends on how long the string might be.  We don't want Java to
generate stack overflows.  It's a nice featre of Java that stack sizes
are usually small.

Andrew.



More information about the Java-patches mailing list