mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
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:
parent
20d95085f5
commit
2a1389023f
2 changed files with 22 additions and 3 deletions
|
@ -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>
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue