#import <objc/zone.h>
#import <stdio.h>
#import <libc.h>
malloc_zone_t *NXDefaultMallocZone() {
return malloc_default_zone();
}
malloc_zone_t *NXCreateZone(size_t startsize, size_t granularity, int canfree) {
return malloc_create_zone(startsize, 0);
}
void NXNameZone(malloc_zone_t *z, const char *name) {
malloc_set_zone_name(z, name);
}
void *NXZoneMalloc(malloc_zone_t *zone, size_t size) {
return malloc_zone_malloc(zone, size);
}
void *NXZoneRealloc(malloc_zone_t *zone, void *ptr, size_t size) {
return malloc_zone_realloc(zone, ptr, size);
}
void *NXZoneCalloc(malloc_zone_t *zone, size_t num_items, size_t size) {
return malloc_zone_calloc(zone, num_items, size);
}
void NXZoneFree(malloc_zone_t *zone, void *ptr) {
malloc_zone_free(zone, ptr);
}
void NXDestroyZone(malloc_zone_t *zone) {
if (zone == malloc_default_zone()) return; malloc_destroy_zone(zone);
}
NXZone *NXZoneFromPtr(void *ptr) {
NXZone *zone = malloc_zone_from_ptr(ptr);
if (!zone) {
malloc_printf("*** NXZoneFromPtr() did not find any zone for %p; returning default\n", ptr);
zone = NX_NOZONE;
}
return zone;
}
void NXAddRegion(void *start, size_t size, malloc_zone_t *zone) {
malloc_printf("*** OBSOLETE: NXAddRegion()\n");
}
void NXRemoveRegion(void *start) {
malloc_printf("*** OBSOLETE: NXRemoveRegion()\n");
}
void NXZonePtrInfo(void *ptr) {
malloc_zone_print_ptr_info(ptr);
}
int NXMallocCheck(void) {
malloc_zone_check(NULL);
return 1;
}
void _NXMallocDumpZones(void) {
malloc_zone_print(NULL, 0);
}
void NXMergeZone(malloc_zone_t *z) {
static char warned = 0;
if (!warned) {
malloc_printf("*** NXMergeZone() now obsolete, does nothing\n");
warned = 1;
}
}
boolean_t NXProtectZone(malloc_zone_t *zone, int protection) {
malloc_printf("*** NXProtectZone() is obsolete\n");
return 0;
}
malloc_zone_t *NXCreateChildZone(malloc_zone_t *parentzone, size_t startsize, size_t granularity, int canfree) {
static char warned = 0;
if (!warned) {
malloc_printf("*** NXCreateChildZone() now obsolete, has been defined to create new zone\n");
warned = 1;
}
return NXCreateZone(startsize, granularity, canfree);
}
void _NXMallocDumpFrees(void) {
malloc_printf("*** OBSOLETE: _NXMallocDumpFrees()\n");
}