3 #include <malloc/malloc.h>
5 // Look for malloc zone "ObjC" iff OBJC_USE_INTERNAL_ZONE is set.
6 // This fails if objc tries to allocate before checking its own
7 // environment variables (rdar://6688423)
13 unsigned int count, i;
14 BOOL has_objc = NO, want_objc = NO;
16 want_objc = (getenv("OBJC_USE_INTERNAL_ZONE") != NULL) ? YES : NO;
17 testprintf("want objc %s\n", want_objc ? "YES" : "NO");
19 kr = malloc_get_all_zones(mach_task_self(), NULL, &zones, &count);
21 for (i = 0; i < count; i++) {
22 const char *name = malloc_get_zone_name((malloc_zone_t *)zones[i]);
24 BOOL is_objc = (0 == strcmp(name, "ObjC")) ? YES : NO;
25 if (is_objc) has_objc = YES;
26 testprintf("zone %s\n", name);
30 testassert(want_objc == has_objc);