2 ms·
This isn't suitable for arrays that large regardless of the resizing multiplier. realloc() generally allocates a new block of memory of the new size, copies th
by eqvinox 4y ago
This isn't suitable for arrays that large regardless of the resizing multiplier.
realloc() generally allocates a new block of memory of the new size, copies the entire content over, and then frees the old block. Only sometimes you get to be lucky and have enough spare room after the existing data in the virtual address map to not need that copy.
By the point this copying becomes relevant, a continuous dynamic array like this becomes fundamentally the wrong data structure.