Loading...
libkern/c++/OSCollection.cpp xnu-792.21.3 xnu-4903.231.4
--- xnu/xnu-792.21.3/libkern/c++/OSCollection.cpp
+++ xnu/xnu-4903.231.4/libkern/c++/OSCollection.cpp
@@ -60,9 +60,17 @@
 
 void OSCollection::haveUpdated()
 {
-    if ( (gIOKitDebug & kOSLogRegistryMods) && (fOptions & kImmutable) )
-	OSReportWithBacktrace("Trying to change a collection in the registry");
-
+    if (fOptions & kImmutable)
+    {
+	if (!(gIOKitDebug & kOSRegistryModsMode))
+	{
+	    panic("Trying to change a collection in the registry");
+	}
+	else
+	{
+	    OSReportWithBacktrace("Trying to change a collection in the registry");
+	}
+    }
     updateStamp++;
 }
 
@@ -94,3 +102,37 @@
 	return this;
     }
 }
+
+bool OSCollection::iterateObjects(void * refcon, bool (*callback)(void * refcon, OSObject * object))
+{
+    uint64_t     iteratorStore[2];
+    unsigned int initialUpdateStamp;
+    bool         done;
+
+    assert(iteratorSize() < sizeof(iteratorStore));
+
+    if (!initIterator(&iteratorStore[0])) return (false);
+
+    initialUpdateStamp = updateStamp;
+    done = false;
+    do
+    {
+        OSObject * object;
+        if (!getNextObjectForIterator(&iteratorStore[0], &object)) break;
+        done = callback(refcon, object);
+    }
+    while (!done && (initialUpdateStamp == updateStamp));
+
+    return initialUpdateStamp == updateStamp;
+}
+
+static bool OSCollectionIterateObjectsBlock(void * refcon, OSObject * object)
+{
+    bool (^block)(OSObject * object) = (typeof(block)) refcon;
+    return (block(object));
+}
+
+bool OSCollection::iterateObjects(bool (^block)(OSObject * object))
+{
+    return (iterateObjects((void *) block, OSCollectionIterateObjectsBlock));
+}