ftp.nice.ch/Attic/openStep/implementation/gnustep/sources/libFoundation.0.7.tgz#/libFoundation-0.7/libFoundation/Foundation/NSZone.h

This is NSZone.h in view mode; [Download] [Up]

/* 
   NSZone.h

   Copyright (C) 1995, 1996 Ovidiu Predescu and Mircea Oancea.
   All rights reserved.

   Author: Ovidiu Predescu <ovidiu@bx.logicnet.ro>

   This file is part of libFoundation.

   Permission to use, copy, modify, and distribute this software and its
   documentation for any purpose and without fee is hereby granted, provided
   that the above copyright notice appear in all copies and that both that
   copyright notice and this permission notice appear in supporting
   documentation.

   We disclaim all warranties with regard to this software, including all
   implied warranties of merchantability and fitness, in no event shall
   we be liable for any special, indirect or consequential damages or any
   damages whatsoever resulting from loss of use, data or profits, whether in
   an action of contract, negligence or other tortious action, arising out of
   or in connection with the use or performance of this software.
*/

#ifndef __NSZone_h__
#define __NSZone_h__

#include <Foundation/NSObject.h>

@class NSString;

#if (__GNUC__ == 2) && (__GNUC_MINOR__ <= 6) && !defined(__attribute__)
#  define __attribute__(x)
#endif

@interface NSZone : NSObject
{
    unsigned	refCount;
    NSString	*name;
}

+ (NSZone*)defaultZone;
+ (NSZone*)zoneFromPointer:(void*)pointer;
+ (BOOL)checkZone;
+ (id)allocZoneInstance;

- initForSize:(unsigned)startSize granularity:(unsigned)granularity
	canFree:(BOOL)canFree;
- (void*)malloc:(unsigned)size;
- (void*)calloc:(unsigned)numElems byteSize:(unsigned)byteSize;
- (void*)realloc:(void*)pointer size:(unsigned)size;
- (void)recycle;
- (BOOL)pointerInZone:(void*)pointer;
- (void)freePointer:(void*)pointer;
- (void)setName:(NSString*)name;
- (NSString*)name;
- (BOOL)checkZone;
@end

/* OpenStep functions */
static inline NSZone *NSCreateZone(unsigned, unsigned, BOOL)
    __attribute__((unused));
static inline NSZone *NSDefaultMallocZone(void) __attribute__((unused));
static inline NSZone *NSZoneFromPointer(void *) __attribute__((unused));
static inline void *NSZoneMalloc(NSZone*, unsigned) __attribute__((unused));
static inline void *NSZoneCalloc(NSZone*, unsigned, unsigned)
    __attribute__((unused));
static inline void *NSZoneRealloc(NSZone*, void*, unsigned)
    __attribute__((unused));
static inline void NSRecycleZone(NSZone*) __attribute__((unused));
static inline void NSZoneFree(NSZone*, void*) __attribute__((unused));
static inline void NSSetZoneName(NSZone*, NSString*) __attribute__((unused));
static inline NSString *NSZoneName(NSZone*) __attribute__((unused));

static inline
NSZone *NSCreateZone(unsigned startSize, unsigned granularity, BOOL canFree)
{
    return [[NSZone alloc] initForSize:startSize
			    granularity:granularity canFree:canFree];
}

static inline
NSZone *NSDefaultMallocZone(void)
{
    return [NSZone defaultZone];
}

static inline
NSZone *NSZoneFromPointer(void *pointer)
{
    return [NSZone zoneFromPointer:pointer];
}

static inline
void *NSZoneMalloc(NSZone *zone, unsigned size)
{
    return zone ? [zone malloc:size] 
	    : [[NSZone defaultZone] malloc:size];
}

static inline
void *NSZoneCalloc(NSZone *zone, unsigned numElems, unsigned byteSize)
{
    return zone ? [zone calloc:numElems byteSize:byteSize]
	    : [[NSZone defaultZone] calloc:numElems byteSize:byteSize];

}

static inline
void *NSZoneRealloc(NSZone *zone, void *pointer, unsigned size)
{
    return zone ? [zone realloc:pointer size:size]
	    : [[NSZone defaultZone] realloc:pointer size:size];
}

static inline
void NSRecycleZone(NSZone *zone)
{
    zone ? [zone recycle] 
	    : [[NSZone defaultZone] recycle];
}

static inline
void NSZoneFree(NSZone *zone, void *pointer)
{
    zone ? [zone freePointer:pointer] 
	    : [[NSZone defaultZone] freePointer:pointer];
}

static inline
void NSSetZoneName(NSZone *zone, NSString *name)
{
    zone ? [zone setName:name]
	    : [[NSZone defaultZone] setName:name];
}

static inline
NSString *NSZoneName(NSZone *zone)
{
    return zone ? [zone name]
	    : [[NSZone defaultZone] name];
}

#endif /* __NSZone_h__ */

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.