Hacker News new | past | comments | ask | show | jobs | submit login

At least with glibc's allocator, realloc() will already go straight to mremap() if your buffer is on the order of megabytes. And if the objects in the buffer can't be moved bytewise (e.g., because they have pointers into themselves), then moving them with mremap() instead of realloc() is hardly going to help.

Of course, C++ being C++, the language-level position is "it's all UB" either way (except for implicit-lifetime types), and even the proposals for trivial relocation make you go through a special function [0].

[0] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p27...






Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: