This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch for Review: JvGetStringUTF and JvTempCString


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]