[libc-commits] [libc] [libc][realpath] Implement symbolic path resolution (PR #204467)

Jackson Stogel via libc-commits libc-commits at lists.llvm.org
Mon Jun 29 15:53:52 PDT 2026


================
@@ -23,6 +23,20 @@
 
 namespace LIBC_NAMESPACE_DECL {
 namespace cpp {
+namespace {
+
+char *realloc_or_die(char *ptr, size_t size) {
+  void *new_ptr = ::realloc(ptr, size);
+  if (new_ptr == nullptr) {
+    // Out of memory: this is not handled in current implementation,
+    // We trap the program and exits.
+    __builtin_trap();
+  }
----------------
jtstogel wrote:

I'm a little concerned about switching, since checks via `LIBC_CRASH_ON_NULLPTR` can be disabled by toggling `LIBC_ADD_NULL_CHECKS`, and I would think in this case we always want to crash regardless of whether null checks are enabled. Or is `LIBC_ADD_NULL_CHECKS` already required for correctness? WDYT?

https://github.com/llvm/llvm-project/pull/204467


More information about the libc-commits mailing list