objc

Instance Methods | Class Methods | Protected Attributes
NXZone Class Reference

A class for managing memory zones. More...

#import <Foundation/Foundation.h>

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

Instance Methods

(void) - dealloc
 Deallocates the memory zone. 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...
 
(void) - dump
 Walks through the zone and outputs information about allocations. More...
 
(size_t) - bytesTotal
 Returns the total size of the memory zone. More...
 
(size_t) - bytesUsed
 Returns the used size of the memory zone. More...
 
(size_t) - bytesFree
 Returns the free size of the memory zone. More...
 
- Instance Methods inherited from NXObject
(id- retain
 Increases the retain count of the receiver. More...
 
(void) - release
 Decreases the retain count of the receiver. More...
 
(id- autorelease
 Adds the receiver to the autorelease pool.
 
- 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...
 
(NXString *) - description
 Returns a string that represents the instance. More...
 
- Instance Methods inherited from <ObjectProtocol>
(BOOL- respondsToSelector:
 Checks if the receiver responds to a selector. More...
 

Class Methods

(id+ defaultZone
 Returns the default memory zone. More...
 
(id+ zoneWithSize:
 Creates a new memory zone with a specified size. More...
 
- Class Methods inherited from NXObject
(id+ allocWithZone:
 Allocates a new instance of an object in a specific memory zone. More...
 
- Class Methods inherited from Object
(void) + initialize
 Performs one-time initialization for the class. More...
 
(id+ alloc
 Allocate a new class instance. 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...
 
(NXString *) + description
 Returns a string that represents the class. More...
 

Protected Attributes

size_t _size
 Initial allocated size of the memory zone in bytes.
 
size_t _count
 Current number of active allocations in the zone.
 
- Protected Attributes inherited from NXObject
id _zone
 The memory zone where the object is allocated.
 
unsigned short _retain
 The retain count of the object.
 
id _next
 The next object in an autorelease pool.
 
- Protected Attributes inherited from Object
Class isa
 A pointer to the object's class structure. More...
 

Detailed Description

A class for managing memory zones.

NXZone provides a mechanism for managing memory allocations. It can be used to create memory arenas of a fixed size, from which objects can be allocated.

Definition at line 23 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, or NULL if the allocation fails.

◆ bytesFree()

- (size_t) bytesFree

Returns the free size of the memory zone.

Returns
The free size of the zone in bytes.

This method returns the number of free bytes in the memory zone.

◆ bytesTotal()

- (size_t) bytesTotal

Returns the total size of the memory zone.

Returns
The total size of the zone in bytes.

This method returns the total capacity of the memory zone in bytes. Note that this includes both used and free memory, plus the size of the NXZone object itself.

◆ bytesUsed()

- (size_t) bytesUsed

Returns the used size of the memory zone.

Returns
The used size of the zone in bytes.

This method returns the number of used bytes in the memory zone.

◆ dealloc()

- (void) dealloc

Deallocates the memory zone.

This frees the memory block managed by the zone.

Implements Object.

◆ defaultZone()

+ (id) defaultZone

Returns the default memory zone.

Returns
The default NXZone instance.

◆ dump()

- (void) dump

Walks through the zone and outputs information about allocations.

This method iterates through all allocations in the zone and prints their addresses and sizes to the log.

◆ free:()

- (void) free: (void *)  ptr

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

Parameters
ptrA pointer to the memory block to be deallocated.

◆ zoneWithSize:()

+ (id) zoneWithSize: (size_t)  size

Creates a new memory zone with a specified size.

Parameters
sizeThe size of the memory zone with initial capacity in bytes.
Returns
A new NXZone instance, or nil if the allocation failed.

This method initializes a new memory zone with the specified capacity in bytes. The zone will be expanded as needed to accommodate additional requirements.


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