Permalink
Browse files

I have a feeling there might be a race condition lurking around here…

  • Loading branch information...
dmoagx committed Jun 15, 2015
1 parent 7335464 commit 0a2f79cf427e8b0cad9f9d70d705269f41181cdb
Showing with 8 additions and 1 deletion.
  1. +8 −1 Source/SPDataStorage.m
@@ -31,6 +31,7 @@
#import "SPDataStorage.h"
#import "SPObjectAdditions.h"
#import <SPMySQL/SPMySQLStreamingResultStore.h>
#include <stdlib.h>
@interface SPDataStorage (Private_API)
@@ -80,7 +81,7 @@ - (void) setDataStorage:(SPMySQLStreamingResultStore *)newDataStorage updatingEx
[self resultStoreDidFinishLoadingData:dataStorage];
}
unloadedColumns = malloc(numberOfColumns * sizeof(BOOL));
unloadedColumns = calloc(numberOfColumns, sizeof(BOOL));
for (i = 0; i < numberOfColumns; i++) {
unloadedColumns[i] = NO;
}
@@ -110,6 +111,7 @@ - (NSMutableArray *) rowContentsAtIndex:(NSUInteger)anIndex
// Modify unloaded cells as appropriate
for (NSUInteger i = 0; i < numberOfColumns; i++) {
NSAssert(unloadedColumns != NULL, @"unloadedColumns not loaded!");
if (unloadedColumns[i]) {
CFArraySetValueAtIndex((CFMutableArrayRef)dataArray, i, [SPNotLoaded notLoaded]);
}
@@ -138,6 +140,7 @@ - (id) cellDataAtRow:(NSUInteger)rowIndex column:(NSUInteger)columnIndex
}
// If the specified column is not loaded, return a SPNotLoaded reference
NSAssert(unloadedColumns != NULL, @"unloadedColumns not loaded!");
if (unloadedColumns[columnIndex]) {
return [SPNotLoaded notLoaded];
}
@@ -172,6 +175,7 @@ - (id) cellPreviewAtRow:(NSUInteger)rowIndex column:(NSUInteger)columnIndex prev
}
// If the specified column is not loaded, return a SPNotLoaded reference
NSAssert(unloadedColumns != NULL, @"unloadedColumns not loaded!");
if (unloadedColumns[columnIndex]) {
return [SPNotLoaded notLoaded];
}
@@ -199,6 +203,7 @@ - (BOOL) cellIsNullOrUnloadedAtRow:(NSUInteger)rowIndex column:(NSUInteger)colum
[NSException raise:NSRangeException format:@"Requested storage column (col %llu) beyond bounds (%llu)", (unsigned long long)columnIndex, (unsigned long long)numberOfColumns];
}
NSAssert(unloadedColumns != NULL, @"unloadedColumns not loaded!");
if (unloadedColumns[columnIndex]) {
return YES;
}
@@ -232,6 +237,7 @@ - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state object
// Modify unloaded cells as appropriate
for (NSUInteger i = 0; i < numberOfColumns; i++) {
NSAssert(unloadedColumns != NULL, @"unloadedColumns not loaded!");
if (unloadedColumns[i]) {
CFArraySetValueAtIndex((CFMutableArrayRef)targetRow, i, [SPNotLoaded notLoaded]);
}
@@ -391,6 +397,7 @@ - (void) setColumnAsUnloaded:(NSUInteger)columnIndex
if (columnIndex >= numberOfColumns) {
[NSException raise:NSRangeException format:@"Invalid column set as unloaded; requested column index (%llu) beyond bounds (%llu)", (unsigned long long)columnIndex, (unsigned long long)numberOfColumns];
}
NSAssert(unloadedColumns != NULL, @"unloadedColumns not loaded!");
unloadedColumns[columnIndex] = YES;
}

0 comments on commit 0a2f79c

Please sign in to comment.