1 //===-- Implementation for freelist_malloc --------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "src/__support/freelist_heap.h" 10 #include "src/__support/macros/config.h" 11 #include "src/stdlib/aligned_alloc.h" 12 #include "src/stdlib/calloc.h" 13 #include "src/stdlib/free.h" 14 #include "src/stdlib/malloc.h" 15 #include "src/stdlib/realloc.h" 16 17 #include <stddef.h> 18 19 namespace LIBC_NAMESPACE_DECL { 20 21 static LIBC_CONSTINIT FreeListHeap freelist_heap_symbols; 22 FreeListHeap *freelist_heap = &freelist_heap_symbols; 23 24 LLVM_LIBC_FUNCTION(void *, malloc, (size_t size)) { 25 return freelist_heap->allocate(size); 26 } 27 28 LLVM_LIBC_FUNCTION(void, free, (void *ptr)) { return freelist_heap->free(ptr); } 29 30 LLVM_LIBC_FUNCTION(void *, calloc, (size_t num, size_t size)) { 31 return freelist_heap->calloc(num, size); 32 } 33 34 LLVM_LIBC_FUNCTION(void *, realloc, (void *ptr, size_t size)) { 35 return freelist_heap->realloc(ptr, size); 36 } 37 38 LLVM_LIBC_FUNCTION(void *, aligned_alloc, (size_t alignment, size_t size)) { 39 return freelist_heap->aligned_allocate(alignment, size); 40 } 41 42 } // namespace LIBC_NAMESPACE_DECL 43