static void ResizeAssociativeSynced (TRI_associative_synced_t* array, uint32_t targetSize) { void** oldTable; uint32_t oldAlloc; uint32_t j; oldTable = array->_table; oldAlloc = array->_nrAlloc; array->_nrAlloc = targetSize; #ifdef TRI_INTERNAL_STATS array->_nrResizes++; #endif array->_table = static_cast<void**>(TRI_Allocate(array->_memoryZone, array->_nrAlloc * sizeof(void*), true)); if (array->_table == NULL) { array->_nrAlloc = oldAlloc; array->_table = oldTable; return; } array->_nrUsed = 0; // table is already cleared by allocate, copy old data for (j = 0; j < oldAlloc; j++) { if (oldTable[j] != NULL) { AddNewElementSynced(array, oldTable[j]); } } TRI_Free(array->_memoryZone, oldTable); }
static void ResizeAssociativeSynced (TRI_associative_synced_t* array) { void** oldTable; uint64_t oldAlloc; uint64_t j; oldTable = array->_table; oldAlloc = array->_nrAlloc; array->_nrAlloc = 2 * array->_nrAlloc + 1; array->_nrUsed = 0; array->_nrResizes++; array->_table = TRI_Allocate(array->_nrAlloc * sizeof(void*)); for (j = 0; j < array->_nrAlloc; j++) { array->_table[j] = NULL; } for (j = 0; j < oldAlloc; j++) { if (oldTable[j] != NULL) { AddNewElementSynced(array, oldTable[j]); } } TRI_Free(oldTable); }