Allow iterating just the keys or values in a hashtable
This commit is contained in:
@@ -18,7 +18,6 @@
|
|||||||
misrepresented as being the original software.
|
misrepresented as being the original software.
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "SDL_internal.h"
|
#include "SDL_internal.h"
|
||||||
#include "SDL_hashtable.h"
|
#include "SDL_hashtable.h"
|
||||||
|
|
||||||
@@ -429,13 +428,21 @@ bool SDL_IterateHashTable(const SDL_HashTable *table, const void **_key, const v
|
|||||||
HT_ASSERT(item <= end);
|
HT_ASSERT(item <= end);
|
||||||
|
|
||||||
if (item == end) {
|
if (item == end) {
|
||||||
|
if (_key) {
|
||||||
*_key = NULL;
|
*_key = NULL;
|
||||||
|
}
|
||||||
|
if (_value) {
|
||||||
*_value = NULL;
|
*_value = NULL;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_key) {
|
||||||
*_key = item->key;
|
*_key = item->key;
|
||||||
|
}
|
||||||
|
if (_value) {
|
||||||
*_value = item->value;
|
*_value = item->value;
|
||||||
|
}
|
||||||
*iter = item;
|
*iter = item;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user