xref: /xnu-10002.81.5/libkern/c++/OSCollectionIterator.cpp (revision 5e3eaea39dcf651e66cb99ba7d70e32cc4a99587)
1*5e3eaea3SApple OSS Distributions /*
2*5e3eaea3SApple OSS Distributions  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3*5e3eaea3SApple OSS Distributions  *
4*5e3eaea3SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*5e3eaea3SApple OSS Distributions  *
6*5e3eaea3SApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*5e3eaea3SApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*5e3eaea3SApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*5e3eaea3SApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*5e3eaea3SApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*5e3eaea3SApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*5e3eaea3SApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*5e3eaea3SApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*5e3eaea3SApple OSS Distributions  *
15*5e3eaea3SApple OSS Distributions  * Please obtain a copy of the License at
16*5e3eaea3SApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*5e3eaea3SApple OSS Distributions  *
18*5e3eaea3SApple OSS Distributions  * The Original Code and all software distributed under the License are
19*5e3eaea3SApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*5e3eaea3SApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*5e3eaea3SApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*5e3eaea3SApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*5e3eaea3SApple OSS Distributions  * Please see the License for the specific language governing rights and
24*5e3eaea3SApple OSS Distributions  * limitations under the License.
25*5e3eaea3SApple OSS Distributions  *
26*5e3eaea3SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*5e3eaea3SApple OSS Distributions  */
28*5e3eaea3SApple OSS Distributions /* IOArray.h created by rsulack on Thu 11-Sep-1997 */
29*5e3eaea3SApple OSS Distributions 
30*5e3eaea3SApple OSS Distributions #define IOKIT_ENABLE_SHARED_PTR
31*5e3eaea3SApple OSS Distributions 
32*5e3eaea3SApple OSS Distributions #include <libkern/c++/OSArray.h>
33*5e3eaea3SApple OSS Distributions #include <libkern/c++/OSCollection.h>
34*5e3eaea3SApple OSS Distributions #include <libkern/c++/OSCollectionIterator.h>
35*5e3eaea3SApple OSS Distributions #include <libkern/c++/OSLib.h>
36*5e3eaea3SApple OSS Distributions #include <libkern/c++/OSSharedPtr.h>
37*5e3eaea3SApple OSS Distributions 
38*5e3eaea3SApple OSS Distributions #define super OSIterator
39*5e3eaea3SApple OSS Distributions 
OSDefineMetaClassAndStructors(OSCollectionIterator,OSIterator)40*5e3eaea3SApple OSS Distributions OSDefineMetaClassAndStructors(OSCollectionIterator, OSIterator)
41*5e3eaea3SApple OSS Distributions 
42*5e3eaea3SApple OSS Distributions bool
43*5e3eaea3SApple OSS Distributions OSCollectionIterator::initWithCollection(const OSCollection *inColl)
44*5e3eaea3SApple OSS Distributions {
45*5e3eaea3SApple OSS Distributions 	if (!super::init() || !inColl) {
46*5e3eaea3SApple OSS Distributions 		return false;
47*5e3eaea3SApple OSS Distributions 	}
48*5e3eaea3SApple OSS Distributions 
49*5e3eaea3SApple OSS Distributions 	collection.reset(inColl, OSRetain);
50*5e3eaea3SApple OSS Distributions 	collIterator = NULL;
51*5e3eaea3SApple OSS Distributions 	initialUpdateStamp = 0;
52*5e3eaea3SApple OSS Distributions 	valid = false;
53*5e3eaea3SApple OSS Distributions 
54*5e3eaea3SApple OSS Distributions 	return true;
55*5e3eaea3SApple OSS Distributions }
56*5e3eaea3SApple OSS Distributions 
57*5e3eaea3SApple OSS Distributions OSSharedPtr<OSCollectionIterator>
withCollection(const OSCollection * inColl)58*5e3eaea3SApple OSS Distributions OSCollectionIterator::withCollection(const OSCollection *inColl)
59*5e3eaea3SApple OSS Distributions {
60*5e3eaea3SApple OSS Distributions 	OSSharedPtr<OSCollectionIterator> me = OSMakeShared<OSCollectionIterator>();
61*5e3eaea3SApple OSS Distributions 
62*5e3eaea3SApple OSS Distributions 	if (me && !me->initWithCollection(inColl)) {
63*5e3eaea3SApple OSS Distributions 		return nullptr;
64*5e3eaea3SApple OSS Distributions 	}
65*5e3eaea3SApple OSS Distributions 
66*5e3eaea3SApple OSS Distributions 	return me;
67*5e3eaea3SApple OSS Distributions }
68*5e3eaea3SApple OSS Distributions 
69*5e3eaea3SApple OSS Distributions void
free()70*5e3eaea3SApple OSS Distributions OSCollectionIterator::free()
71*5e3eaea3SApple OSS Distributions {
72*5e3eaea3SApple OSS Distributions 	freeIteratorStorage();
73*5e3eaea3SApple OSS Distributions 
74*5e3eaea3SApple OSS Distributions 	collection.reset();
75*5e3eaea3SApple OSS Distributions 
76*5e3eaea3SApple OSS Distributions 	super::free();
77*5e3eaea3SApple OSS Distributions }
78*5e3eaea3SApple OSS Distributions 
79*5e3eaea3SApple OSS Distributions void
reset()80*5e3eaea3SApple OSS Distributions OSCollectionIterator::reset()
81*5e3eaea3SApple OSS Distributions {
82*5e3eaea3SApple OSS Distributions 	valid = false;
83*5e3eaea3SApple OSS Distributions 	bool initialized = initializeIteratorStorage();
84*5e3eaea3SApple OSS Distributions 
85*5e3eaea3SApple OSS Distributions 	if (!initialized) {
86*5e3eaea3SApple OSS Distributions 		// reusing existing storage
87*5e3eaea3SApple OSS Distributions 		void * storage = getIteratorStorage();
88*5e3eaea3SApple OSS Distributions 		bzero(storage, collection->iteratorSize());
89*5e3eaea3SApple OSS Distributions 
90*5e3eaea3SApple OSS Distributions 		if (!collection->initIterator(storage)) {
91*5e3eaea3SApple OSS Distributions 			return;
92*5e3eaea3SApple OSS Distributions 		}
93*5e3eaea3SApple OSS Distributions 
94*5e3eaea3SApple OSS Distributions 		initialUpdateStamp = collection->updateStamp;
95*5e3eaea3SApple OSS Distributions 		valid = true;
96*5e3eaea3SApple OSS Distributions 	}
97*5e3eaea3SApple OSS Distributions }
98*5e3eaea3SApple OSS Distributions 
99*5e3eaea3SApple OSS Distributions bool
isValid()100*5e3eaea3SApple OSS Distributions OSCollectionIterator::isValid()
101*5e3eaea3SApple OSS Distributions {
102*5e3eaea3SApple OSS Distributions 	initializeIteratorStorage();
103*5e3eaea3SApple OSS Distributions 
104*5e3eaea3SApple OSS Distributions 	if (!valid || collection->updateStamp != initialUpdateStamp) {
105*5e3eaea3SApple OSS Distributions 		return false;
106*5e3eaea3SApple OSS Distributions 	}
107*5e3eaea3SApple OSS Distributions 
108*5e3eaea3SApple OSS Distributions 	return true;
109*5e3eaea3SApple OSS Distributions }
110*5e3eaea3SApple OSS Distributions 
111*5e3eaea3SApple OSS Distributions bool
initializeIteratorStorage()112*5e3eaea3SApple OSS Distributions OSCollectionIterator::initializeIteratorStorage()
113*5e3eaea3SApple OSS Distributions {
114*5e3eaea3SApple OSS Distributions 	void * result = NULL;
115*5e3eaea3SApple OSS Distributions 	bool initialized = false;
116*5e3eaea3SApple OSS Distributions 
117*5e3eaea3SApple OSS Distributions #if __LP64__
118*5e3eaea3SApple OSS Distributions 	OSCollectionIteratorStorageType storageType = getStorageType();
119*5e3eaea3SApple OSS Distributions 	switch (storageType) {
120*5e3eaea3SApple OSS Distributions 	case OSCollectionIteratorStorageUnallocated:
121*5e3eaea3SApple OSS Distributions 		if (collection->iteratorSize() > sizeof(inlineStorage) || isSubclassed()) {
122*5e3eaea3SApple OSS Distributions 			collIterator = (void *)kalloc_data(collection->iteratorSize(), Z_WAITOK);
123*5e3eaea3SApple OSS Distributions 			OSCONTAINER_ACCUMSIZE(collection->iteratorSize());
124*5e3eaea3SApple OSS Distributions 			if (!collection->initIterator(collIterator)) {
125*5e3eaea3SApple OSS Distributions 				kfree_data(collIterator, collection->iteratorSize());
126*5e3eaea3SApple OSS Distributions 				OSCONTAINER_ACCUMSIZE(-((size_t) collection->iteratorSize()));
127*5e3eaea3SApple OSS Distributions 				collIterator = NULL;
128*5e3eaea3SApple OSS Distributions 				initialized = false;
129*5e3eaea3SApple OSS Distributions 				setStorageType(OSCollectionIteratorStorageUnallocated);
130*5e3eaea3SApple OSS Distributions 			} else {
131*5e3eaea3SApple OSS Distributions 				setStorageType(OSCollectionIteratorStoragePointer);
132*5e3eaea3SApple OSS Distributions 				result = collIterator;
133*5e3eaea3SApple OSS Distributions 				initialized = true;
134*5e3eaea3SApple OSS Distributions 			}
135*5e3eaea3SApple OSS Distributions 		} else {
136*5e3eaea3SApple OSS Distributions 			bzero(&inlineStorage[0], collection->iteratorSize());
137*5e3eaea3SApple OSS Distributions 			if (!collection->initIterator(&inlineStorage[0])) {
138*5e3eaea3SApple OSS Distributions 				bzero(&inlineStorage[0], collection->iteratorSize());
139*5e3eaea3SApple OSS Distributions 				initialized = false;
140*5e3eaea3SApple OSS Distributions 				setStorageType(OSCollectionIteratorStorageUnallocated);
141*5e3eaea3SApple OSS Distributions 			} else {
142*5e3eaea3SApple OSS Distributions 				setStorageType(OSCollectionIteratorStorageInline);
143*5e3eaea3SApple OSS Distributions 				result = &inlineStorage[0];
144*5e3eaea3SApple OSS Distributions 				initialized = true;
145*5e3eaea3SApple OSS Distributions 			}
146*5e3eaea3SApple OSS Distributions 		}
147*5e3eaea3SApple OSS Distributions 		break;
148*5e3eaea3SApple OSS Distributions 	case OSCollectionIteratorStoragePointer:
149*5e3eaea3SApple OSS Distributions 		// already initialized
150*5e3eaea3SApple OSS Distributions 		initialized = false;
151*5e3eaea3SApple OSS Distributions 		break;
152*5e3eaea3SApple OSS Distributions 	case OSCollectionIteratorStorageInline:
153*5e3eaea3SApple OSS Distributions 		// already initialized
154*5e3eaea3SApple OSS Distributions 		initialized = false;
155*5e3eaea3SApple OSS Distributions 		break;
156*5e3eaea3SApple OSS Distributions 	default:
157*5e3eaea3SApple OSS Distributions 		panic("unexpected storage type %u", storageType);
158*5e3eaea3SApple OSS Distributions 	}
159*5e3eaea3SApple OSS Distributions #else
160*5e3eaea3SApple OSS Distributions 	if (!collIterator) {
161*5e3eaea3SApple OSS Distributions 		collIterator = (void *)kalloc_data(collection->iteratorSize(), Z_WAITOK);
162*5e3eaea3SApple OSS Distributions 		OSCONTAINER_ACCUMSIZE(collection->iteratorSize());
163*5e3eaea3SApple OSS Distributions 		if (!collection->initIterator(collIterator)) {
164*5e3eaea3SApple OSS Distributions 			kfree_data(collIterator, collection->iteratorSize());
165*5e3eaea3SApple OSS Distributions 			OSCONTAINER_ACCUMSIZE(-((size_t) collection->iteratorSize()));
166*5e3eaea3SApple OSS Distributions 			collIterator = NULL;
167*5e3eaea3SApple OSS Distributions 			initialized = false;
168*5e3eaea3SApple OSS Distributions 			setStorageType(OSCollectionIteratorStorageUnallocated);
169*5e3eaea3SApple OSS Distributions 		} else {
170*5e3eaea3SApple OSS Distributions 			setStorageType(OSCollectionIteratorStoragePointer);
171*5e3eaea3SApple OSS Distributions 			result = collIterator;
172*5e3eaea3SApple OSS Distributions 			initialized = true;
173*5e3eaea3SApple OSS Distributions 		}
174*5e3eaea3SApple OSS Distributions 	}
175*5e3eaea3SApple OSS Distributions #endif /* __LP64__ */
176*5e3eaea3SApple OSS Distributions 
177*5e3eaea3SApple OSS Distributions 	if (initialized) {
178*5e3eaea3SApple OSS Distributions 		valid = true;
179*5e3eaea3SApple OSS Distributions 		initialUpdateStamp = collection->updateStamp;
180*5e3eaea3SApple OSS Distributions 	}
181*5e3eaea3SApple OSS Distributions 
182*5e3eaea3SApple OSS Distributions 	return initialized;
183*5e3eaea3SApple OSS Distributions }
184*5e3eaea3SApple OSS Distributions 
185*5e3eaea3SApple OSS Distributions void *
getIteratorStorage()186*5e3eaea3SApple OSS Distributions OSCollectionIterator::getIteratorStorage()
187*5e3eaea3SApple OSS Distributions {
188*5e3eaea3SApple OSS Distributions 	void * result = NULL;
189*5e3eaea3SApple OSS Distributions 
190*5e3eaea3SApple OSS Distributions #if __LP64__
191*5e3eaea3SApple OSS Distributions 	OSCollectionIteratorStorageType storageType = getStorageType();
192*5e3eaea3SApple OSS Distributions 
193*5e3eaea3SApple OSS Distributions 	switch (storageType) {
194*5e3eaea3SApple OSS Distributions 	case OSCollectionIteratorStorageUnallocated:
195*5e3eaea3SApple OSS Distributions 		result = NULL;
196*5e3eaea3SApple OSS Distributions 		break;
197*5e3eaea3SApple OSS Distributions 	case OSCollectionIteratorStoragePointer:
198*5e3eaea3SApple OSS Distributions 		result = collIterator;
199*5e3eaea3SApple OSS Distributions 		break;
200*5e3eaea3SApple OSS Distributions 	case OSCollectionIteratorStorageInline:
201*5e3eaea3SApple OSS Distributions 		result = &inlineStorage[0];
202*5e3eaea3SApple OSS Distributions 		break;
203*5e3eaea3SApple OSS Distributions 	default:
204*5e3eaea3SApple OSS Distributions 		panic("unexpected storage type %u", storageType);
205*5e3eaea3SApple OSS Distributions 	}
206*5e3eaea3SApple OSS Distributions #else
207*5e3eaea3SApple OSS Distributions 	OSCollectionIteratorStorageType storageType __assert_only = getStorageType();
208*5e3eaea3SApple OSS Distributions 	assert(storageType == OSCollectionIteratorStoragePointer || storageType == OSCollectionIteratorStorageUnallocated);
209*5e3eaea3SApple OSS Distributions 	result = collIterator;
210*5e3eaea3SApple OSS Distributions #endif /* __LP64__ */
211*5e3eaea3SApple OSS Distributions 
212*5e3eaea3SApple OSS Distributions 	return result;
213*5e3eaea3SApple OSS Distributions }
214*5e3eaea3SApple OSS Distributions 
215*5e3eaea3SApple OSS Distributions void
freeIteratorStorage()216*5e3eaea3SApple OSS Distributions OSCollectionIterator::freeIteratorStorage()
217*5e3eaea3SApple OSS Distributions {
218*5e3eaea3SApple OSS Distributions #if __LP64__
219*5e3eaea3SApple OSS Distributions 	OSCollectionIteratorStorageType storageType = getStorageType();
220*5e3eaea3SApple OSS Distributions 
221*5e3eaea3SApple OSS Distributions 	switch (storageType) {
222*5e3eaea3SApple OSS Distributions 	case OSCollectionIteratorStorageUnallocated:
223*5e3eaea3SApple OSS Distributions 		break;
224*5e3eaea3SApple OSS Distributions 	case OSCollectionIteratorStoragePointer:
225*5e3eaea3SApple OSS Distributions 		kfree_data(collIterator, collection->iteratorSize());
226*5e3eaea3SApple OSS Distributions 		OSCONTAINER_ACCUMSIZE(-((size_t) collection->iteratorSize()));
227*5e3eaea3SApple OSS Distributions 		collIterator = NULL;
228*5e3eaea3SApple OSS Distributions 		setStorageType(OSCollectionIteratorStorageUnallocated);
229*5e3eaea3SApple OSS Distributions 		break;
230*5e3eaea3SApple OSS Distributions 	case OSCollectionIteratorStorageInline:
231*5e3eaea3SApple OSS Distributions 		bzero(&inlineStorage[0], collection->iteratorSize());
232*5e3eaea3SApple OSS Distributions 		setStorageType(OSCollectionIteratorStorageUnallocated);
233*5e3eaea3SApple OSS Distributions 		break;
234*5e3eaea3SApple OSS Distributions 	default:
235*5e3eaea3SApple OSS Distributions 		panic("unexpected storage type %u", storageType);
236*5e3eaea3SApple OSS Distributions 	}
237*5e3eaea3SApple OSS Distributions #else
238*5e3eaea3SApple OSS Distributions 	if (collIterator != NULL) {
239*5e3eaea3SApple OSS Distributions 		assert(getStorageType() == OSCollectionIteratorStoragePointer);
240*5e3eaea3SApple OSS Distributions 		kfree_data(collIterator, collection->iteratorSize());
241*5e3eaea3SApple OSS Distributions 		OSCONTAINER_ACCUMSIZE(-((size_t) collection->iteratorSize()));
242*5e3eaea3SApple OSS Distributions 		collIterator = NULL;
243*5e3eaea3SApple OSS Distributions 		setStorageType(OSCollectionIteratorStorageUnallocated);
244*5e3eaea3SApple OSS Distributions 	} else {
245*5e3eaea3SApple OSS Distributions 		assert(getStorageType() == OSCollectionIteratorStorageUnallocated);
246*5e3eaea3SApple OSS Distributions 	}
247*5e3eaea3SApple OSS Distributions #endif /* __LP64__ */
248*5e3eaea3SApple OSS Distributions }
249*5e3eaea3SApple OSS Distributions 
250*5e3eaea3SApple OSS Distributions bool
isSubclassed()251*5e3eaea3SApple OSS Distributions OSCollectionIterator::isSubclassed()
252*5e3eaea3SApple OSS Distributions {
253*5e3eaea3SApple OSS Distributions 	return getMetaClass() != OSCollectionIterator::metaClass;
254*5e3eaea3SApple OSS Distributions }
255*5e3eaea3SApple OSS Distributions 
256*5e3eaea3SApple OSS Distributions OSCollectionIteratorStorageType
getStorageType()257*5e3eaea3SApple OSS Distributions OSCollectionIterator::getStorageType()
258*5e3eaea3SApple OSS Distributions {
259*5e3eaea3SApple OSS Distributions #if __LP64__
260*5e3eaea3SApple OSS Distributions 	// Storage type is in the most significant 2 bits of collIterator
261*5e3eaea3SApple OSS Distributions 	return (OSCollectionIteratorStorageType)((uintptr_t)(collIterator) >> 62);
262*5e3eaea3SApple OSS Distributions #else
263*5e3eaea3SApple OSS Distributions 	if (collIterator != NULL) {
264*5e3eaea3SApple OSS Distributions 		return OSCollectionIteratorStoragePointer;
265*5e3eaea3SApple OSS Distributions 	} else {
266*5e3eaea3SApple OSS Distributions 		return OSCollectionIteratorStorageUnallocated;
267*5e3eaea3SApple OSS Distributions 	}
268*5e3eaea3SApple OSS Distributions #endif /* __LP64__ */
269*5e3eaea3SApple OSS Distributions }
270*5e3eaea3SApple OSS Distributions 
271*5e3eaea3SApple OSS Distributions void
setStorageType(OSCollectionIteratorStorageType storageType)272*5e3eaea3SApple OSS Distributions OSCollectionIterator::setStorageType(OSCollectionIteratorStorageType storageType)
273*5e3eaea3SApple OSS Distributions {
274*5e3eaea3SApple OSS Distributions #if __LP64__
275*5e3eaea3SApple OSS Distributions 	switch (storageType) {
276*5e3eaea3SApple OSS Distributions 	case OSCollectionIteratorStorageUnallocated:
277*5e3eaea3SApple OSS Distributions 		if (collIterator != NULL) {
278*5e3eaea3SApple OSS Distributions 			assert(getStorageType() == OSCollectionIteratorStorageInline);
279*5e3eaea3SApple OSS Distributions 			collIterator = NULL;
280*5e3eaea3SApple OSS Distributions 		}
281*5e3eaea3SApple OSS Distributions 		break;
282*5e3eaea3SApple OSS Distributions 	case OSCollectionIteratorStoragePointer:
283*5e3eaea3SApple OSS Distributions 		// Should already be set
284*5e3eaea3SApple OSS Distributions 		assert(collIterator != NULL);
285*5e3eaea3SApple OSS Distributions 		assert(getStorageType() == OSCollectionIteratorStoragePointer);
286*5e3eaea3SApple OSS Distributions 		break;
287*5e3eaea3SApple OSS Distributions 	case OSCollectionIteratorStorageInline:
288*5e3eaea3SApple OSS Distributions 		// Set the two most sigificant bits of collIterator to 10b
289*5e3eaea3SApple OSS Distributions 		collIterator = (void *)(((uintptr_t)collIterator & ~0xC000000000000000) | ((uintptr_t)OSCollectionIteratorStorageInline << 62));
290*5e3eaea3SApple OSS Distributions 		break;
291*5e3eaea3SApple OSS Distributions 	default:
292*5e3eaea3SApple OSS Distributions 		panic("unexpected storage type %u", storageType);
293*5e3eaea3SApple OSS Distributions 	}
294*5e3eaea3SApple OSS Distributions #else
295*5e3eaea3SApple OSS Distributions 	switch (storageType) {
296*5e3eaea3SApple OSS Distributions 	case OSCollectionIteratorStorageUnallocated:
297*5e3eaea3SApple OSS Distributions 		// Should already be set
298*5e3eaea3SApple OSS Distributions 		assert(collIterator == NULL);
299*5e3eaea3SApple OSS Distributions 		assert(getStorageType() == OSCollectionIteratorStorageUnallocated);
300*5e3eaea3SApple OSS Distributions 		break;
301*5e3eaea3SApple OSS Distributions 	case OSCollectionIteratorStoragePointer:
302*5e3eaea3SApple OSS Distributions 		// Should already be set
303*5e3eaea3SApple OSS Distributions 		assert(collIterator != NULL);
304*5e3eaea3SApple OSS Distributions 		assert(getStorageType() == OSCollectionIteratorStoragePointer);
305*5e3eaea3SApple OSS Distributions 		break;
306*5e3eaea3SApple OSS Distributions 	case OSCollectionIteratorStorageInline:
307*5e3eaea3SApple OSS Distributions 		panic("cannot use inline storage on LP32");
308*5e3eaea3SApple OSS Distributions 		break;
309*5e3eaea3SApple OSS Distributions 	default:
310*5e3eaea3SApple OSS Distributions 		panic("unexpected storage type %u", storageType);
311*5e3eaea3SApple OSS Distributions 	}
312*5e3eaea3SApple OSS Distributions #endif /* __LP64__ */
313*5e3eaea3SApple OSS Distributions }
314*5e3eaea3SApple OSS Distributions 
315*5e3eaea3SApple OSS Distributions OSObject *
getNextObject()316*5e3eaea3SApple OSS Distributions OSCollectionIterator::getNextObject()
317*5e3eaea3SApple OSS Distributions {
318*5e3eaea3SApple OSS Distributions 	OSObject *retObj;
319*5e3eaea3SApple OSS Distributions 	bool retVal;
320*5e3eaea3SApple OSS Distributions 	void * storage;
321*5e3eaea3SApple OSS Distributions 
322*5e3eaea3SApple OSS Distributions 	if (!isValid()) {
323*5e3eaea3SApple OSS Distributions 		return NULL;
324*5e3eaea3SApple OSS Distributions 	}
325*5e3eaea3SApple OSS Distributions 
326*5e3eaea3SApple OSS Distributions 	storage = getIteratorStorage();
327*5e3eaea3SApple OSS Distributions 	assert(storage != NULL);
328*5e3eaea3SApple OSS Distributions 
329*5e3eaea3SApple OSS Distributions 	retVal = collection->getNextObjectForIterator(storage, &retObj);
330*5e3eaea3SApple OSS Distributions 	return (retVal)? retObj : NULL;
331*5e3eaea3SApple OSS Distributions }
332