mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-20 20:26:42 +00:00
Tweak to prevent stack overflow on windows, without significant loss of
performance ... use stack for smallish temporary storage, but heap for larger storage requirements. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17860 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7e1ee0cfa4
commit
2ed87acf65
4 changed files with 57 additions and 23 deletions
|
@ -24,6 +24,17 @@
|
|||
#define __GSPrivate_h_
|
||||
|
||||
|
||||
/*
|
||||
* Macros to manage memory for chunks of code that need to work with
|
||||
* arrays of objects. Use OBUFBEGIN() to start the block of code using
|
||||
* the array and OBUFEND() to end it. The idea is to ensure that small
|
||||
* arrays are allocated on the stack (for speed), but large arrays are
|
||||
* allocated from the heap (to avoid stack overflow).
|
||||
*/
|
||||
#define OBUFMAX 1024
|
||||
#define OBUFBEGIN(P, S) { id _xxx[(S) <= OBUFMAX ? (S) : 0]; id *(P) = ((S) <= OBUFMAX) ? _xxx : (id*)NSZoneMalloc(NSDefaultMallocZone(), (S) * sizeof(id));
|
||||
#define OBUFEND(P, S) if ((S) > OBUFMAX) NSZoneFree(NSDefaultMallocZone(), (P)); }
|
||||
|
||||
/*
|
||||
* Function to get the name of a string encoding as an NSString.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue