+/********* Batch methods ************/
+
+unsigned
+malloc_zone_batch_malloc(malloc_zone_t *zone, size_t size, void **results, unsigned num_requested) {
+ unsigned (*batch_malloc)(malloc_zone_t *, size_t, void **, unsigned) = zone-> batch_malloc;
+ if (! batch_malloc) return 0;
+ if (malloc_check_start && (malloc_check_counter++ >= malloc_check_start)) {
+ internal_check();
+ }
+ unsigned batched = batch_malloc(zone, size, results, num_requested);
+ if (malloc_logger) {
+ unsigned index = 0;
+ while (index < batched) {
+ malloc_logger(MALLOC_LOG_TYPE_ALLOCATE | MALLOC_LOG_TYPE_HAS_ZONE, (unsigned)zone, size, 0, (unsigned)results[index], 0);
+ index++;
+ }
+ }
+ return batched;
+}
+
+void
+malloc_zone_batch_free(malloc_zone_t *zone, void **to_be_freed, unsigned num) {
+ if (malloc_check_start && (malloc_check_counter++ >= malloc_check_start)) {
+ internal_check();
+ }
+ if (malloc_logger) {
+ unsigned index = 0;
+ while (index < num) {
+ malloc_logger(MALLOC_LOG_TYPE_DEALLOCATE | MALLOC_LOG_TYPE_HAS_ZONE, (unsigned)zone, (unsigned)to_be_freed[index], 0, 0, 0);
+ index++;
+ }
+ }
+ void (*batch_free)(malloc_zone_t *, void **, unsigned) = zone-> batch_free;
+ if (batch_free) {
+ batch_free(zone, to_be_freed, num);
+ } else {
+ void (*free_fun)(malloc_zone_t *, void *) = zone->free;
+ while (num--) {
+ void *ptr = *to_be_freed++;
+ free_fun(zone, ptr);
+ }
+ }
+}
+