Skip to content

Commit

Permalink
Fixed bug in transferring values
Browse files Browse the repository at this point in the history
  • Loading branch information
odrobnik committed Nov 1, 2013
1 parent 3e8fb94 commit 6de65b7
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions Core/Source/DTRangesArray.m
Expand Up @@ -45,24 +45,16 @@ - (NSUInteger)count

- (void)_extendCapacity
{
if (!_capacity)
if (_capacity)
{
_capacity = _capacity*2;
_ranges = realloc(_ranges, _capacity * sizeof(NSRange));
}
else
{
_capacity = 100;
_ranges = calloc(_capacity, sizeof(NSRange));
return;
_ranges = malloc(_capacity * sizeof(NSRange));
}

// double capacity
NSUInteger newCapacity = _capacity*2;
NSRange *newRanges = calloc(newCapacity, sizeof(NSRange));

// copy old
memcpy(newRanges, _ranges, _capacity);

// move to new block
free(_ranges);
_ranges = newRanges;
_capacity = newCapacity;
}

- (void)addRange:(NSRange)range
Expand Down

0 comments on commit 6de65b7

Please sign in to comment.