Core functions for object allocation and memory management.
MulleObjCInstanceGetAllocator
- Gets allocator for instanceMulleObjCInstanceAllocateMemory
- Allocates zeroed memoryMulleObjCInstanceAllocateNonZeroedMemory
- Allocates raw memoryMulleObjCInstanceReallocateNonZeroedMemory
- Resizes memory blockMulleObjCInstanceDeallocateMemory
- Frees allocated memoryMulleObjCInstanceDuplicateUTF8String
- Copies string using instance allocator
MulleObjCClassGetAllocator
- Gets allocator for classMulleObjCClassAllocateMemory
- Allocates zeroed memoryMulleObjCClassDeallocateMemory
- Frees allocated memoryMulleObjCClassDuplicateUTF8String
- Copies string using class allocator
MulleObjCThreadSetAllocator
- Sets thread-local allocatorMulleObjCThreadGetAllocator
- Gets thread-local allocator
// Allocate memory for instance
id obj = self;
void *memory = MulleObjCInstanceAllocateMemory(obj, 1024);
// Use memory
// ...
// Free when done
MulleObjCInstanceDeallocateMemory(obj, memory);
-
Memory Management
- All allocations must be freed with corresponding deallocate function
- Use instance allocator for instance-specific memory
- Use class allocator for shared class memory
-
Thread Safety
- Allocation functions are thread-safe
- Each thread can have its own allocator
- Thread allocator affects all allocations in that thread