|
31 | 31 | #import "SPDataStorage.h" |
32 | 32 | #import "SPObjectAdditions.h" |
33 | 33 | #import <SPMySQL/SPMySQLStreamingResultStore.h> |
| 34 | +#include <stdlib.h> |
34 | 35 |
|
35 | 36 | @interface SPDataStorage (Private_API) |
36 | 37 |
|
@@ -80,7 +81,7 @@ - (void) setDataStorage:(SPMySQLStreamingResultStore *)newDataStorage updatingEx |
80 | 81 | [self resultStoreDidFinishLoadingData:dataStorage]; |
81 | 82 | } |
82 | 83 |
|
83 | | - unloadedColumns = malloc(numberOfColumns * sizeof(BOOL)); |
| 84 | + unloadedColumns = calloc(numberOfColumns, sizeof(BOOL)); |
84 | 85 | for (i = 0; i < numberOfColumns; i++) { |
85 | 86 | unloadedColumns[i] = NO; |
86 | 87 | } |
@@ -110,6 +111,7 @@ - (NSMutableArray *) rowContentsAtIndex:(NSUInteger)anIndex |
110 | 111 |
|
111 | 112 | // Modify unloaded cells as appropriate |
112 | 113 | for (NSUInteger i = 0; i < numberOfColumns; i++) { |
| 114 | + NSAssert(unloadedColumns != NULL, @"unloadedColumns not loaded!"); |
113 | 115 | if (unloadedColumns[i]) { |
114 | 116 | CFArraySetValueAtIndex((CFMutableArrayRef)dataArray, i, [SPNotLoaded notLoaded]); |
115 | 117 | } |
@@ -138,6 +140,7 @@ - (id) cellDataAtRow:(NSUInteger)rowIndex column:(NSUInteger)columnIndex |
138 | 140 | } |
139 | 141 |
|
140 | 142 | // If the specified column is not loaded, return a SPNotLoaded reference |
| 143 | + NSAssert(unloadedColumns != NULL, @"unloadedColumns not loaded!"); |
141 | 144 | if (unloadedColumns[columnIndex]) { |
142 | 145 | return [SPNotLoaded notLoaded]; |
143 | 146 | } |
@@ -172,6 +175,7 @@ - (id) cellPreviewAtRow:(NSUInteger)rowIndex column:(NSUInteger)columnIndex prev |
172 | 175 | } |
173 | 176 |
|
174 | 177 | // If the specified column is not loaded, return a SPNotLoaded reference |
| 178 | + NSAssert(unloadedColumns != NULL, @"unloadedColumns not loaded!"); |
175 | 179 | if (unloadedColumns[columnIndex]) { |
176 | 180 | return [SPNotLoaded notLoaded]; |
177 | 181 | } |
@@ -199,6 +203,7 @@ - (BOOL) cellIsNullOrUnloadedAtRow:(NSUInteger)rowIndex column:(NSUInteger)colum |
199 | 203 | [NSException raise:NSRangeException format:@"Requested storage column (col %llu) beyond bounds (%llu)", (unsigned long long)columnIndex, (unsigned long long)numberOfColumns]; |
200 | 204 | } |
201 | 205 |
|
| 206 | + NSAssert(unloadedColumns != NULL, @"unloadedColumns not loaded!"); |
202 | 207 | if (unloadedColumns[columnIndex]) { |
203 | 208 | return YES; |
204 | 209 | } |
@@ -232,6 +237,7 @@ - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state object |
232 | 237 |
|
233 | 238 | // Modify unloaded cells as appropriate |
234 | 239 | for (NSUInteger i = 0; i < numberOfColumns; i++) { |
| 240 | + NSAssert(unloadedColumns != NULL, @"unloadedColumns not loaded!"); |
235 | 241 | if (unloadedColumns[i]) { |
236 | 242 | CFArraySetValueAtIndex((CFMutableArrayRef)targetRow, i, [SPNotLoaded notLoaded]); |
237 | 243 | } |
@@ -391,6 +397,7 @@ - (void) setColumnAsUnloaded:(NSUInteger)columnIndex |
391 | 397 | if (columnIndex >= numberOfColumns) { |
392 | 398 | [NSException raise:NSRangeException format:@"Invalid column set as unloaded; requested column index (%llu) beyond bounds (%llu)", (unsigned long long)columnIndex, (unsigned long long)numberOfColumns]; |
393 | 399 | } |
| 400 | + NSAssert(unloadedColumns != NULL, @"unloadedColumns not loaded!"); |
394 | 401 | unloadedColumns[columnIndex] = YES; |
395 | 402 | } |
396 | 403 |
|
|
0 commit comments