3 ms·
If you were to implement your own realloc for the purpose of this data structure, you could do that. However, a generic realloc implementation needs to know how
by dooglius 4mo ago
If you were to implement your own realloc for the purpose of this data structure, you could do that. However, a generic realloc implementation needs to know how many bytes to copy, and generally that means storing the capacity just in front of the allocated region. I don't think there is another feasible way. On e.g. glibc, you can use `malloc_usable_size` to extract this information (modulo certain caveats).