bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArray: Problem allocating memory on stack on windows


From: David Ayers
Subject: Re: NSArray: Problem allocating memory on stack on windows
Date: Fri, 24 Oct 2003 18:39:33 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5) Gecko/20031007

Richard Frith-Macdonald wrote:


There is now some experimental code in NSArray.m in CVS to use the heap for numbers of objects above 1000 (an arbitrary choice). It uses a couple of new macros which will probably eventually make their way to GSObjCRuntime.h once we've picked better names
and decided on a good number ... perhaps nearer 100.

Hello Richard,

Because by convention we currently prefer autoreleased objects in GDL2 and GSWeb, we have the need for a version of this macro that uses the GSAutoreleasedBuffer. I've also played with allowing different types, making sure the size is evaluated only once and making the identifiers unique so that you could use multiple buffers in the the same block. Have a look at it and see if we should apply something this to the versions in -base also:

#define GDL2_BUFFER(ID, SIZE, TYPE) \
 unsigned ID##_size = (SIZE); \
 TYPE ID##_obuf[(ID##_size) <= GS_MAX_OBJECTS_FROM_STACK ? (ID##_size) : 0]; \
 TYPE *ID##_base = ((ID##_size) <= GS_MAX_OBJECTS_FROM_STACK) ? ID##_obuf \
   : ( TYPE *)GSAutoreleasedBuffer((ID##_size) * sizeof( TYPE )); \
 TYPE *ID = ID##_base;


For the non-autorelease version, we may want to consider (optionally ?) adding exception handling to free the buffer if necessary.

Cheers,
David






reply via email to

[Prev in Thread] Current Thread [Next in Thread]