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: Thu, 09 Oct 2003 13:31:35 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5) Gecko/20030916

Richard Frith-Macdonald wrote:

Unfortunately, having two ways of dealing with the memory means more code, and more chance of bugs ... so generally when adopting this scheme I initially set the changeover point very small, so it's easy to exercise both schemes,
and only increase it when I'm confident both are working well.

FYI:

I've been usimg the following scheme in GDL2:

...
     unsigned i;
     id        obj[cnt>GS_MAX_OBJECTS_FROM_STACK?0:cnt];
     id       *objPStart;
     id       *objP;
     id        anObject;
....
     objPStart = objP = (max > GS_MAX_OBJECTS_FROM_STACK)?
       GSAutoreleasedBuffer(sizeof(id)*cnt):obj;

     for(i=0; i < cnt; i++)
       {
         anObject = ...;
         ...
         *objP++=anObject;
       }
     return [NSArray arrayWithObjects: objPStart count: objP - objPStart];

Of course the autoreleasing should be avoided in your case so a second test would be needed to free the memory. But if anyone as any bright ideas :-)

Cheers,
David







reply via email to

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