picofuse-objc

Instance Methods | Class Methods | List of all members
NXZone Class Reference

A region of memory, from which objects and other memory can be allocated. More...

#import <Foundation/Foundation.h>

Inheritance diagram for NXZone:
Inheritance graph
[legend]
Collaboration diagram for NXZone:
Collaboration graph
[legend]

Instance Methods

(void) - dealloc
 Frees the zone and its memory. More...
 
(void *) - allocWithSize:
 Allocates a block of memory from the zone. More...
 
(void) - free:
 Frees a block of memory that was allocated from the zone. More...
 
(size_t) - count
 Returns the number of blocks of memory which are allocated.
 
(size_t) - bytesTotal
 Returns the capacity of the zone in bytes.
 
(size_t) - bytesUsed
 Returns the number of bytes which are allocated.
 
(size_t) - bytesFree
 Returns the number of bytes which aren't allocated. More...
 
- Instance Methods inherited from NXObject
(NXZone *) - zone
 Returns the zone in which the instance was allocated. More...
 
(id) - retain
 Increases the retain count of the receiver. More...
 
(void) - release
 Decreases the retain count of the receiver. More...
 
(id) - autorelease
 Releases the receiver later, when the current autorelease pool of the thread is drained. More...
 
(id) - copy
 Returns a copy which can't be changed by anything else, which the caller owns and has to release. More...
 
(uintptr_t) - hash
 Returns a number for the object, which is the same for objects which are equal by isEqual:. More...
 
(NXString *) - description
 Returns a string which describes the instance, for logging. More...
 
- Instance Methods inherited from Object
(id) - init
 Initialize the instance, after allocation. More...
 
(Class) - class
 Returns the class of the instance. More...
 
(Class) - superclass
 Returns the superclass of the instance. More...
 
(BOOL) - isEqual:
 Compares the receiver to another object for equality. More...
 
(BOOL) - isKindOfClass:
 Returns a Boolean value that indicates whether the receiver is an instance of a given class. More...
 
(BOOL) - conformsTo:
 Checks if the receiver's class conforms to a protocol. More...
 
- Instance Methods inherited from <ObjectProtocol>
(BOOL) - respondsToSelector:
 Checks if the receiver responds to a selector. More...
 

Class Methods

(NXZone *) + defaultZone
 Returns the default zone. More...
 
(id) + zoneWithSize:
 Creates a new zone. More...
 
- Class Methods inherited from NXObject
(id) + alloc
 Allocates a new instance in the default zone, or if there isn't one, with sys_calloc(). More...
 
(id) + allocWithZone:
 Allocates a new instance in a specific zone. More...
 
(id) + new
 Allocates and initializes a new instance, as [[cls alloc] init] does. More...
 
(NXString *) + description
 Returns the name of the class.
 
- Class Methods inherited from Object
(void) + initialize
 Performs one-time initialization for the class. More...
 
(Class) + class
 Returns the class object. More...
 
(Class) + superclass
 Returns the superclass of the class. More...
 
(const char *) + name
 Returns the name of the class. More...
 
(BOOL) + conformsTo:
 Checks if the class conforms to a protocol. More...
 

Additional Inherited Members

- Protected Attributes inherited from Object
Class isa
 A pointer to the object's class structure. More...
 

Detailed Description

A region of memory, from which objects and other memory can be allocated.

A zone is a chain of picofuse arenas. It starts with one, and another is added whenever there isn't room in those it has.

The first zone created becomes the default zone, in which objects are allocated. When it's deallocated, there's no default zone until another zone is created.

Any thread can use a zone, as it locks itself. See Threads and mutable objects.

Definition at line 24 of file NXZone.h.

Method Documentation

◆ allocWithSize:()

- (void *) allocWithSize: (size_t)  size

Allocates a block of memory from the zone.

Parameters
sizeThe number of bytes to allocate.
Returns
A pointer to the allocated memory, which isn't initialized, or NULL if the size is zero or the allocation failed.

◆ bytesFree()

- (size_t) bytesFree

Returns the number of bytes which aren't allocated.

Not all of it can be, as some is used to keep track of each allocation.

◆ dealloc()

- (void) dealloc

Frees the zone and its memory.

Panics if any memory allocated from the zone hasn't been freed.

Implements NXObject.

◆ defaultZone()

+ (NXZone *) defaultZone

Returns the default zone.

Returns
The default zone, or nil if there isn't one. It isn't retained, so it can be deallocated if another thread releases it.

◆ free:()

- (void) free: (void *)  ptr

Frees a block of memory that was allocated from the zone.

Panics if it wasn't.

Parameters
ptrA pointer to the memory block. Nothing is done if it's NULL.

◆ zoneWithSize:()

+ (id) zoneWithSize: (size_t)  size

Creates a new zone.

Parameters
sizeThe initial capacity of the zone in bytes. Some of that is used to keep track of each allocation.
Returns
A new zone, or nil if the allocation failed. It should be released when it's no longer needed.

If there's no default zone, the new zone becomes the default zone.


The documentation for this class was generated from the following file: