From 72f35d976995cddb2c9c05af86cbda794153e47a Mon Sep 17 00:00:00 2001 From: Alistair Leszkiewicz Date: Tue, 7 Aug 2012 11:39:05 +1000 Subject: [PATCH 1/2] Added NS_BLOCK_ASSERTIONS ifdef around assertion --- JSONKit.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/JSONKit.m b/JSONKit.m index 0e9331f..95db54d 100644 --- a/JSONKit.m +++ b/JSONKit.m @@ -919,7 +919,9 @@ static void _JKDictionaryResizeIfNeccessary(JKDictionary *dictionary) { NSUInteger idx = 0UL; for(idx = 0UL; idx < oldCapacity; idx++) { if(oldEntry[idx].key != NULL) { _JKDictionaryAddObject(dictionary, oldEntry[idx].keyHash, oldEntry[idx].key, oldEntry[idx].object); oldEntry[idx].keyHash = 0UL; oldEntry[idx].key = NULL; oldEntry[idx].object = NULL; } } +#ifndef NS_BLOCK_ASSERTIONS NSCParameterAssert((oldCount == dictionary->count)); +#endif free(oldEntry); oldEntry = NULL; } } From 5e5d02c200e154824a218b337042628331936ebb Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 1 Mar 2013 15:40:25 +1100 Subject: [PATCH 2/2] update replace objective-c's isa with object_setClass() --- JSONKit.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/JSONKit.m b/JSONKit.m index 95db54d..8f4accf 100644 --- a/JSONKit.m +++ b/JSONKit.m @@ -677,7 +677,7 @@ + (id)allocWithZone:(NSZone *)zone NSCParameterAssert((objects != NULL) && (_JKArrayClass != NULL) && (_JKArrayInstanceSize > 0UL)); JKArray *array = NULL; if(JK_EXPECT_T((array = (JKArray *)calloc(1UL, _JKArrayInstanceSize)) != NULL)) { // Directly allocate the JKArray instance via calloc. - array->isa = _JKArrayClass; + object_setClass(array, _JKArrayClass); if((array = [array init]) == NULL) { return(NULL); } array->capacity = count; array->count = count; @@ -930,7 +930,7 @@ static void _JKDictionaryResizeIfNeccessary(JKDictionary *dictionary) { NSCParameterAssert((keys != NULL) && (keyHashes != NULL) && (objects != NULL) && (_JKDictionaryClass != NULL) && (_JKDictionaryInstanceSize > 0UL)); JKDictionary *dictionary = NULL; if(JK_EXPECT_T((dictionary = (JKDictionary *)calloc(1UL, _JKDictionaryInstanceSize)) != NULL)) { // Directly allocate the JKDictionary instance via calloc. - dictionary->isa = _JKDictionaryClass; + object_setClass(dictionary, _JKDictionaryClass); if((dictionary = [dictionary init]) == NULL) { return(NULL); } dictionary->capacity = _JKDictionaryCapacityForCount(count); dictionary->count = 0UL;