2 ms·
No, I don't. If you look at the code in question, every time I expand an allocation I at least double it.
by cperciva 11y ago
No, I don't. If you look at the code in question, every time I expand an allocation I at least double it.
- acqq 11y agoI'd expect that such growth seldom allows the realloc to remain in-place (unless it's the last thing allocated before and already in a big preallocated chunk of the allocator)? Have you observed what you then get in your program? Which allocator is used underneath?
- cperciva 11y agoI haven't looked. I use whatever allocator is in libc anyway, so it will depend on what platform you're running on. At worst, using realloc produces the same results as malloc/memcpy/free. At best, it might save a memcpy. No harm in giving it that flexibility.