[PATCH] D52401: Remove redundant null pointer check in operator delete
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 30 18:41:11 PDT 2018
MaskRay added a comment.
I just checked an extremely old version of glibc fetched from https://ftp.gnu.org/pub/gnu/glibc/
glibc-2.0.1.tar.gz 1997-02-04 03:00 3.7M
`malloc/malloc.c`
#if __STD_C
void fREe(Void_t* mem)
#else
void fREe(mem) Void_t* mem;
#endif
{
arena *ar_ptr;
mchunkptr p; /* chunk corresponding to mem */
#if defined(_LIBC) || defined(MALLOC_HOOKS)
if (__free_hook != NULL) {
(*__free_hook)(mem);
return;
}
#endif
if (mem == 0) /* free(0) has no effect */
return;
`__free_hook` (defaults to NULL) is a user-supplied hook (https://www.gnu.org/software/libc/manual/html_node/Hooks-for-Malloc.html). If this failed for `operator delete`, it would mean various other `free(NULL)` would also fail.
Repository:
rL LLVM
https://reviews.llvm.org/D52401
More information about the llvm-commits
mailing list