diff options
| author | Arthur Eubanks <aeubanks@google.com> | 2024-06-27 16:32:27 -0700 |
|---|---|---|
| committer | shawbyoung <shawbyoung@gmail.com> | 2024-06-27 16:32:27 -0700 |
| commit | f5c7df12cacdb84552b36a7ac598a8db41acc680 (patch) | |
| tree | 3b33e941b9bfb88c40c64fd18ee32a633423cbed /libc/src/stdlib/freelist_malloc.cpp | |
| parent | 608880c3a7a59c86db82728067e553a8d4665a45 (diff) | |
| parent | 804415825b97e974c96a92580bcbeaf4c7ff0a04 (diff) | |
[𝘀𝗽𝗿] changes introduced through rebaseusers/shawbyoung/spr/main.boltnfc-refactoring-callgraph
Created using spr 1.3.4
[skip ci]
Diffstat (limited to 'libc/src/stdlib/freelist_malloc.cpp')
| -rw-r--r-- | libc/src/stdlib/freelist_malloc.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/libc/src/stdlib/freelist_malloc.cpp b/libc/src/stdlib/freelist_malloc.cpp new file mode 100644 index 000000000000..4d3c42ca90ba --- /dev/null +++ b/libc/src/stdlib/freelist_malloc.cpp @@ -0,0 +1,45 @@ +//===-- Implementation for freelist_malloc --------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "src/__support/freelist_heap.h" +#include "src/stdlib/calloc.h" +#include "src/stdlib/free.h" +#include "src/stdlib/malloc.h" +#include "src/stdlib/realloc.h" + +#include <stddef.h> + +namespace LIBC_NAMESPACE { + +namespace { +#ifdef LIBC_FREELIST_MALLOC_SIZE +// This is set via the LIBC_CONF_FREELIST_MALLOC_BUFFER_SIZE configuration. +constexpr size_t SIZE = LIBC_FREELIST_MALLOC_SIZE; +#else +#error "LIBC_FREELIST_MALLOC_SIZE was not defined for this build." +#endif +LIBC_CONSTINIT FreeListHeapBuffer<SIZE> freelist_heap_buffer; +} // namespace + +FreeListHeap<> *freelist_heap = &freelist_heap_buffer; + +LLVM_LIBC_FUNCTION(void *, malloc, (size_t size)) { + return freelist_heap->allocate(size); +} + +LLVM_LIBC_FUNCTION(void, free, (void *ptr)) { return freelist_heap->free(ptr); } + +LLVM_LIBC_FUNCTION(void *, calloc, (size_t num, size_t size)) { + return freelist_heap->calloc(num, size); +} + +LLVM_LIBC_FUNCTION(void *, realloc, (void *ptr, size_t size)) { + return freelist_heap->realloc(ptr, size); +} + +} // namespace LIBC_NAMESPACE |
