revert last

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32069 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2011-02-11 12:43:47 +00:00
parent 20d95085f5
commit 2a1389023f
2 changed files with 22 additions and 3 deletions

View file

@ -2,7 +2,6 @@
* Source/GSICUString.m:
Fix leak spotted by static analyser.
Temporarily revert change to GSPrivate.h so code compiles again.
2011-02-11 12:06 David Chisnall <theraven@gna.org>

View file

@ -93,21 +93,41 @@ typedef struct objc_category* Category;
* arrays are allocated on the stack (for speed), but large arrays are
* allocated from the heap (to avoid stack overflow).
*/
#define GS_BEGINITEMBUF(P, S, T) { \
#if __GNUC__ > 3
__attribute__((unused)) static void GSFreeTempBuffer(void **b)
{
if (NULL != *b) free(*b);
}
# define GS_BEGINITEMBUF(P, S, T) { \
T _ibuf[GS_MAX_OBJECTS_FROM_STACK];\
T *P = _ibuf;\
__attribute__((cleanup(GSFreeTempBuffer))) void *_base = 0;\
if (S > GS_MAX_OBJECTS_FROM_STACK)\
{\
_base = malloc(S);\
P = _base;\
}
#else
# define GS_BEGINITEMBUF(P, S, T) { \
T _ibuf[(S) <= GS_MAX_OBJECTS_FROM_STACK ? (S) : 0]; \
T *_base = ((S) <= GS_MAX_OBJECTS_FROM_STACK) ? _ibuf \
: (T*)NSZoneMalloc(NSDefaultMallocZone(), (S) * sizeof(T)); \
T *(P) = _base;
#endif
/**
* Macro to manage memory for chunks of code that need to work with
* arrays of items. Use GS_BEGINITEMBUF() to start the block of code using
* the array and this macro to end it.
*/
#define GS_ENDITEMBUF() \
#if __GNUC__ > 3
# define GS_ENDITEMBUF() }
#else
# define GS_ENDITEMBUF() \
if (_base != _ibuf) \
NSZoneFree(NSDefaultMallocZone(), _base); \
}
#endif
/**
* Macro to manage memory for chunks of code that need to work with