mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Added NSZoneMallocAtomic() and tidied
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4277 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2a345153a7
commit
87909743ac
2 changed files with 65 additions and 17 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri May 21 16:40:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Source/include/NSZone.h: Added NSZoneMallocAtomic() for Helge
|
||||
and in anticipation of adding garbage collection support some day.
|
||||
|
||||
Fri May 21 9:56:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Source/include/NSObject.h: Bracket macro definitions with #ifndef
|
||||
|
|
|
@ -126,6 +126,17 @@ extern inline NSString* NSZoneName (NSZone *zone)
|
|||
return nil;
|
||||
}
|
||||
|
||||
#ifndef NO_GNUSTEP
|
||||
|
||||
extern inline void* NSZoneMallocAtomic (NSZone *zone, size_t size)
|
||||
{
|
||||
void *ptr = (void*)GC_MALLOC_ATOMIC(size);
|
||||
|
||||
if (ptr == 0)
|
||||
ptr = GSOutOfMemory(size, YES);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern inline BOOL NSZoneCheck (NSZone *zone)
|
||||
{
|
||||
return YES;
|
||||
|
@ -136,48 +147,80 @@ extern inline struct NSZoneStats NSZoneStats (NSZone *zone)
|
|||
struct NSZoneStats stats = { 0 };
|
||||
return stats;
|
||||
}
|
||||
#endif
|
||||
|
||||
#else /* GS_WITH_GC */
|
||||
|
||||
extern NSZone* NSCreateZone (size_t start, size_t gran, BOOL canFree);
|
||||
|
||||
extern inline NSZone* NSDefaultMallocZone (void)
|
||||
{ return __nszone_private_hidden_default_zone; }
|
||||
{
|
||||
return __nszone_private_hidden_default_zone;
|
||||
}
|
||||
|
||||
extern NSZone* NSZoneFromPointer (void *ptr);
|
||||
|
||||
extern inline void* NSZoneMalloc (NSZone *zone, size_t size)
|
||||
{ if (!zone) zone = NSDefaultMallocZone();
|
||||
return (zone->malloc)(zone, size); }
|
||||
{
|
||||
if (!zone)
|
||||
zone = NSDefaultMallocZone();
|
||||
return (zone->malloc)(zone, size);
|
||||
}
|
||||
|
||||
extern void* NSZoneCalloc (NSZone *zone, size_t elems, size_t bytes);
|
||||
|
||||
extern inline void* NSZoneRealloc (NSZone *zone, void *ptr, size_t size)
|
||||
{ if (!zone) zone = NSDefaultMallocZone();
|
||||
return (zone->realloc)(zone, ptr, size); }
|
||||
{
|
||||
if (!zone)
|
||||
zone = NSDefaultMallocZone();
|
||||
return (zone->realloc)(zone, ptr, size);
|
||||
}
|
||||
|
||||
extern inline void NSRecycleZone (NSZone *zone)
|
||||
{ if (!zone) zone = NSDefaultMallocZone();
|
||||
(zone->recycle)(zone); }
|
||||
{
|
||||
if (!zone)
|
||||
zone = NSDefaultMallocZone();
|
||||
(zone->recycle)(zone);
|
||||
}
|
||||
|
||||
extern inline void NSZoneFree (NSZone *zone, void *ptr)
|
||||
{ if (!zone) zone = NSDefaultMallocZone();
|
||||
(zone->free)(zone, ptr); }
|
||||
{
|
||||
if (!zone)
|
||||
zone = NSDefaultMallocZone();
|
||||
(zone->free)(zone, ptr);
|
||||
}
|
||||
|
||||
extern void NSSetZoneName (NSZone *zone, NSString *name);
|
||||
|
||||
extern inline NSString* NSZoneName (NSZone *zone)
|
||||
{ if (!zone) zone = NSDefaultMallocZone();
|
||||
return zone->name; }
|
||||
{
|
||||
if (!zone)
|
||||
zone = NSDefaultMallocZone();
|
||||
return zone->name;
|
||||
}
|
||||
|
||||
extern inline BOOL NSZoneCheck (NSZone *zone) // Not in OpenStep
|
||||
{ if (!zone) zone = NSDefaultMallocZone();
|
||||
return (zone->check)(zone); }
|
||||
#ifndef NO_GNUSTEP
|
||||
extern inline void* NSZoneMallocAtomic (NSZone *zone, size_t size)
|
||||
{
|
||||
if (!zone)
|
||||
zone = NSDefaultMallocZone();
|
||||
return (zone->malloc)(zone, size);
|
||||
}
|
||||
|
||||
extern inline BOOL NSZoneCheck (NSZone *zone)
|
||||
{
|
||||
if (!zone)
|
||||
zone = NSDefaultMallocZone();
|
||||
return (zone->check)(zone);
|
||||
}
|
||||
|
||||
/* Not in OpenStep */
|
||||
extern inline struct NSZoneStats NSZoneStats (NSZone *zone)
|
||||
{ if (!zone) zone = NSDefaultMallocZone();
|
||||
return (zone->stats)(zone); }
|
||||
{
|
||||
if (!zone)
|
||||
zone = NSDefaultMallocZone();
|
||||
return (zone->stats)(zone);
|
||||
}
|
||||
#endif /* NO_GNUSTEP */
|
||||
|
||||
#endif /* GS_WITH_GC */
|
||||
|
||||
|
|
Loading…
Reference in a new issue