diff options
Diffstat (limited to '')
-rw-r--r-- | src/packedintarray.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/packedintarray.cpp b/src/packedintarray.cpp index 5397a73..b91358e 100644 --- a/src/packedintarray.cpp +++ b/src/packedintarray.cpp | |||
@@ -207,14 +207,16 @@ void PackedIntArray::checkCapacity() | |||
207 | { | 207 | { |
208 | // Bu::println("!!! Resizing !!!"); | 208 | // Bu::println("!!! Resizing !!!"); |
209 | Store *aOldData = aData; | 209 | Store *aOldData = aData; |
210 | int iNewSize = StoreCount(iCapacity*2); | 210 | int iNewSize = (iCapacity==0)?(bitsizeof(Store)/iBitWidth):(iCapacity=StoreCount(iCapacity*2)); |
211 | while( iNewSize < iCount ) | ||
212 | iNewSize *= 2; | ||
211 | int iSize = StoreCount(iCapacity); | 213 | int iSize = StoreCount(iCapacity); |
212 | // Bu::println(" %1 => %2 (%3 bit words)").arg( iSize ).arg( iNewSize ) | 214 | // Bu::println(" %1 => %2 (%3 bit words)").arg( iSize ).arg( iNewSize ) |
213 | // .arg( StoreBits ); | 215 | // .arg( StoreBits ); |
214 | aData = new Store[iNewSize]; | 216 | aData = new Store[iNewSize]; |
215 | memset( aData, 0, iNewSize*sizeof(Store) ); | 217 | memset( aData, 0, iNewSize*sizeof(Store) ); |
216 | memcpy( aData, aOldData, iSize*sizeof(Store) ); | 218 | memcpy( aData, aOldData, iSize*sizeof(Store) ); |
217 | iCapacity *= 2; | 219 | iCapacity = (iNewSize*bitsizeof(Store))/iBitWidth; |
218 | delete[] aOldData; | 220 | delete[] aOldData; |
219 | } | 221 | } |
220 | } | 222 | } |