10 ms·
Yes, but the C standard also allows a realloc() that can never actually succeed in growing the allocation. The probability by which a given allocation pattern
by marshray 13y ago
Yes, but the C standard also allows a realloc() that can never actually succeed in growing the allocation.
The probability by which a given allocation pattern is likely to result in a successful growing realloc() seems like a pretty big design choice.
Do you leave space after allocations for them to grow? Do you have power-of-2 size-based tables with an allocation bitmap? If so, what sizes? Etc.
- spc476 13y agoWhich is why you might get back a new pointer---because the original block couldn't be grown, so a new block has to be allocated and the contents copied.