5 #include <malloc/malloc.h>
7 // Look for malloc zone "ObjC" iff OBJC_USE_INTERNAL_ZONE is set.
8 // This fails if objc tries to allocate before checking its own
9 // environment variables (rdar://6688423)
13 if (is_guardmalloc()) {
14 // guard malloc confuses this test
20 unsigned int count, i;
21 BOOL has_objc = NO, want_objc = NO;
23 want_objc = (getenv("OBJC_USE_INTERNAL_ZONE") != NULL) ? YES : NO;
24 testprintf("want objc %s\n", want_objc ? "YES" : "NO");
26 kr = malloc_get_all_zones(mach_task_self(), NULL, &zones, &count);
28 for (i = 0; i < count; i++) {
29 const char *name = malloc_get_zone_name((malloc_zone_t *)zones[i]);
31 BOOL is_objc = (0 == strcmp(name, "ObjC_Internal")) ? YES : NO;
32 if (is_objc) has_objc = YES;
33 testprintf("zone %s\n", name);
37 testassert(want_objc == has_objc);