mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 17:12:03 +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
c0eaedb49a
commit
40e08a0da9
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>
|
Fri May 21 9:56:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
* Source/include/NSObject.h: Bracket macro definitions with #ifndef
|
* Source/include/NSObject.h: Bracket macro definitions with #ifndef
|
||||||
|
|
|
@ -126,6 +126,17 @@ extern inline NSString* NSZoneName (NSZone *zone)
|
||||||
return nil;
|
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)
|
extern inline BOOL NSZoneCheck (NSZone *zone)
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
|
@ -136,48 +147,80 @@ extern inline struct NSZoneStats NSZoneStats (NSZone *zone)
|
||||||
struct NSZoneStats stats = { 0 };
|
struct NSZoneStats stats = { 0 };
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#else /* GS_WITH_GC */
|
#else /* GS_WITH_GC */
|
||||||
|
|
||||||
extern NSZone* NSCreateZone (size_t start, size_t gran, BOOL canFree);
|
extern NSZone* NSCreateZone (size_t start, size_t gran, BOOL canFree);
|
||||||
|
|
||||||
extern inline NSZone* NSDefaultMallocZone (void)
|
extern inline NSZone* NSDefaultMallocZone (void)
|
||||||
{ return __nszone_private_hidden_default_zone; }
|
{
|
||||||
|
return __nszone_private_hidden_default_zone;
|
||||||
|
}
|
||||||
|
|
||||||
extern NSZone* NSZoneFromPointer (void *ptr);
|
extern NSZone* NSZoneFromPointer (void *ptr);
|
||||||
|
|
||||||
extern inline void* NSZoneMalloc (NSZone *zone, size_t size)
|
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 void* NSZoneCalloc (NSZone *zone, size_t elems, size_t bytes);
|
||||||
|
|
||||||
extern inline void* NSZoneRealloc (NSZone *zone, void *ptr, size_t size)
|
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)
|
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)
|
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 void NSSetZoneName (NSZone *zone, NSString *name);
|
||||||
|
|
||||||
extern inline NSString* NSZoneName (NSZone *zone)
|
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
|
#ifndef NO_GNUSTEP
|
||||||
{ if (!zone) zone = NSDefaultMallocZone();
|
extern inline void* NSZoneMallocAtomic (NSZone *zone, size_t size)
|
||||||
return (zone->check)(zone); }
|
{
|
||||||
|
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)
|
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 */
|
#endif /* GS_WITH_GC */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue