]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/zalloc.c
xnu-3789.60.24.tar.gz
[apple/xnu.git] / osfmk / kern / zalloc.c
index f9649749f7d545854c8ebbfeeeb5fd9f4ca434ba..be40d82600f487c1b5b1e8ad906703c88b4db863 100644 (file)
@@ -356,14 +356,13 @@ struct zone_free_element {
 };
 
 /*
- *      Protects num_zones, zone_array and zone_array_index
+ *      Protects num_zones and zone_array
  */
 decl_simple_lock_data(, all_zones_lock)
 unsigned int            num_zones;
 
 #define MAX_ZONES       256
 struct zone             zone_array[MAX_ZONES];
-static int              zone_array_index = 0;
 
 #define MULTIPAGE_METADATA_MAGIC               (0xff)
 
@@ -1565,9 +1564,10 @@ zinit(
        zone_t          z;
 
        simple_lock(&all_zones_lock);
-       z = &(zone_array[zone_array_index]);
-       zone_array_index++;
-       assert(zone_array_index != MAX_ZONES);
+       assert(num_zones < MAX_ZONES);
+       z = &(zone_array[num_zones]);
+       z->index = num_zones;
+       num_zones++;
        simple_unlock(&all_zones_lock);
 
        /* Zone elements must fit both a next pointer and a backup pointer */
@@ -1640,14 +1640,6 @@ zinit(
 
        lock_zone_init(z);
 
-       /*
-        *      Add the zone to the all-zones list.
-        */
-       simple_lock(&all_zones_lock);
-       z->index = num_zones;
-       num_zones++;
-       simple_unlock(&all_zones_lock);
-
        /*
         * Check for and set up zone leak detection if requested via boot-args.  We recognized two
         * boot-args: