请参阅此链接。只需将标记为 - 的行替换为标记为 + 的行。
- if((array = [array init]) == NULL) { return(NULL); }
+ if([array init] == NULL) { free(array); return(NULL); }
- if(JK_EXPECT_F((array->objects = (id *)malloc(sizeof(id) * array->capacity)) == NULL)) { [array autorelease]; return(NULL); }
+ if(JK_EXPECT_F((array->objects = (id *)malloc(sizeof(id) * array->capacity)) == NULL)) { free(array); return(NULL); }
- if((dictionary = [dictionary init]) == NULL) { return(NULL); }
+ if([dictionary init] == NULL) { free(dictionary);return(NULL); }
- if(JK_EXPECT_F((dictionary->entry = (JKHashTableEntry *)calloc(1UL, sizeof(JKHashTableEntry) * dictionary->capacity)) == NULL)) { [dictionary autorelease]; return(NULL); }
+ if(JK_EXPECT_F((dictionary->entry = (JKHashTableEntry *)calloc(1UL, sizeof(JKHashTableEntry) * dictionary->capacity)) == NULL)) { free(dictionary); return(NULL); }