+boolean_t
+malloc_zone_enable_discharge_checking(malloc_zone_t *zone)
+{
+ if (zone->version < 7) // Version must be >= 7 to look at the new discharge checking fields.
+ return FALSE;
+ if (NULL == zone->introspect->enable_discharge_checking)
+ return FALSE;
+ return zone->introspect->enable_discharge_checking(zone);
+}
+
+void
+malloc_zone_disable_discharge_checking(malloc_zone_t *zone)
+{
+ if (zone->version < 7) // Version must be >= 7 to look at the new discharge checking fields.
+ return;
+ if (NULL == zone->introspect->disable_discharge_checking)
+ return;
+ zone->introspect->disable_discharge_checking(zone);
+}
+
+void
+malloc_zone_discharge(malloc_zone_t *zone, void *memory)
+{
+ if (NULL == zone)
+ zone = malloc_zone_from_ptr(memory);
+ if (NULL == zone)
+ return;
+ if (zone->version < 7) // Version must be >= 7 to look at the new discharge checking fields.
+ return;
+ if (NULL == zone->introspect->discharge)
+ return;
+ zone->introspect->discharge(zone, memory);
+}
+
+void
+malloc_zone_enumerate_discharged_pointers(malloc_zone_t *zone, void (^report_discharged)(void *memory, void *info))
+{
+ if (!zone) {
+ unsigned index = 0;
+ while (index < malloc_num_zones) {
+ zone = malloc_zones[index++];
+ if (zone->version < 7)
+ continue;
+ if (NULL == zone->introspect->enumerate_discharged_pointers)
+ continue;
+ zone->introspect->enumerate_discharged_pointers(zone, report_discharged);
+ }
+ } else {
+ if (zone->version < 7)
+ return;
+ if (NULL == zone->introspect->enumerate_discharged_pointers)
+ return;
+ zone->introspect->enumerate_discharged_pointers(zone, report_discharged);
+ }
+}
+