Legacy memory management structure in mulle-objc that provides zone-based memory allocation compatibility.
NSCreateZone
- Creates new zone (returns NULL)NSRecycleZone
- Frees zone (no-op)NSDefaultMallocZone
- Gets default zone (returns NULL)
NSZoneMalloc
- Allocates memory in zoneNSZoneCalloc
- Allocates zeroed memoryNSZoneRealloc
- Reallocates memoryNSZoneFree
- Frees memory
NSAllocateObject
- Allocates object in zoneNSReallocateObject
- Reallocates objectNSDeallocateObject
- Deallocates object
// Create zone (returns NULL)
NSZone *zone = NSCreateZone(1024, 128, YES);
// Allocate memory in zone
void *memory = NSZoneMalloc(zone, size);
// Reallocate memory in zone
void *newMemory = NSZoneRealloc(zone, memory, newSize);
// Free memory in zone
NSZoneFree(zone, memory);
// Object allocation
id object = NSAllocateObject(class, extraBytes, zone);
-
Compatibility
- Legacy code support
- API compatibility
- Zero overhead
-
Memory Management
- Standard allocation
- Direct mapping
- No zone overhead
-
Modern Code
- Prefer standard allocation
- Remove zone usage
- Simplify interfaces
-
Best Practices
- Use direct allocation
- Minimize indirection
- Optimize memory usage