[all-commits] [llvm/llvm-project] f34003: [libc] Add custom operator new to handle allocatio...

Siva Chandra via All-commits all-commits at lists.llvm.org
Sat Dec 10 16:29:27 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f3400305771d4e0084d2ebc8e3e5d2736ba3bd7c
      https://github.com/llvm/llvm-project/commit/f3400305771d4e0084d2ebc8e3e5d2736ba3bd7c
  Author: Siva Chandra Reddy <sivachandra at google.com>
  Date:   2022-12-11 (Sun, 11 Dec 2022)

  Changed paths:
    A libc/src/__support/CPP/new.h
    M libc/src/string/CMakeLists.txt
    M libc/src/string/allocating_string_utils.h
    M libc/src/string/strdup.cpp
    M libc/src/unistd/linux/getcwd.cpp
    M libc/test/src/string/CMakeLists.txt
    M libc/test/src/string/strdup_test.cpp

  Log Message:
  -----------
  [libc] Add custom operator new to handle allocation failures gracefully.

This patch adds the implementation of the custom operator new functions.
The implementation of the internal strdup has been updated to use
operator new for allocation.

We will make it a policy and document that all allocations have to go
through the libc's own operator new. A future change will also add
operator delete replacements and make it a policy that deallocations in
libc internal code have to go through those replacements.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D139584




More information about the All-commits mailing list