If you think about it, growing and shrinking an allocation are actually 2 very different operations. The only reason for merging them together is historical, because C did it.
If you look at Vec, the biggest user of realloc, you will see that growing and shrinking are two completely separate code paths. Similarly, within allocator implementations, growing and shrinking are also often handled differently.
As such, it makes sense to remove realloc and realloc_zeroed and add three new methods:
If you think about it, growing and shrinking an allocation are actually 2 very different operations. The only reason for merging them together is historical, because C did it.
If you look at
Vec, the biggest user ofrealloc, you will see that growing and shrinking are two completely separate code paths. Similarly, within allocator implementations, growing and shrinking are also often handled differently.As such, it makes sense to remove
reallocandrealloc_zeroedand add three new methods:growgrow_zeroedshrink