[PATCH] D63668: [Support] Improve zero-size allocation with safe_malloc, etc.

Hubert Tong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 24 16:40:46 PDT 2019


hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.

LGTM with minor comment (that can be applied when committing).



================
Comment at: llvm/include/llvm/Support/MemAlloc.h:28
+  if (Result == nullptr) {
+    if (Sz == 0)
+      return safe_malloc(1);
----------------
Suggested comment before this line (and similarly for the other two functions):
```
    // It is implementation-defined whether allocation occurs if the space
    // requested is zero (ISO/IEC 9899:2018 7.22.3). Retry, requesting non-zero,
    // if the space requested was zero.
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63668/new/

https://reviews.llvm.org/D63668





More information about the llvm-commits mailing list