22#if defined(__clang__) || defined(__GNUC__)
23#define RPMALLOC_EXPORT __attribute__((visibility("default")))
24#define RPMALLOC_ALLOCATOR
25#if (defined(__clang_major__) && (__clang_major__ < 4)) || \
26 (defined(__GNUC__) && defined(ENABLE_PRELOAD) && ENABLE_PRELOAD)
27#define RPMALLOC_ATTRIB_MALLOC
28#define RPMALLOC_ATTRIB_ALLOC_SIZE(size)
29#define RPMALLOC_ATTRIB_ALLOC_SIZE2(count, size)
31#define RPMALLOC_ATTRIB_MALLOC __attribute__((__malloc__))
32#define RPMALLOC_ATTRIB_ALLOC_SIZE(size) __attribute__((alloc_size(size)))
33#define RPMALLOC_ATTRIB_ALLOC_SIZE2(count, size) \
34 __attribute__((alloc_size(count, size)))
37#elif defined(_MSC_VER)
38#define RPMALLOC_EXPORT
39#define RPMALLOC_ALLOCATOR __declspec(allocator) __declspec(restrict)
40#define RPMALLOC_ATTRIB_MALLOC
41#define RPMALLOC_ATTRIB_ALLOC_SIZE(size)
42#define RPMALLOC_ATTRIB_ALLOC_SIZE2(count, size)
43#define RPMALLOC_CDECL __cdecl
45#define RPMALLOC_EXPORT
46#define RPMALLOC_ALLOCATOR
47#define RPMALLOC_ATTRIB_MALLOC
48#define RPMALLOC_ATTRIB_ALLOC_SIZE(size)
49#define RPMALLOC_ATTRIB_ALLOC_SIZE2(count, size)
56#ifndef RPMALLOC_CONFIGURABLE
57#define RPMALLOC_CONFIGURABLE 0
63#ifndef RPMALLOC_FIRST_CLASS_HEAPS
64#define RPMALLOC_FIRST_CLASS_HEAPS 0
68#define RPMALLOC_NO_PRESERVE 1
73#define RPMALLOC_GROW_OR_FAIL 2
169 void *(*memory_map)(
size_t size,
size_t *offset);
335#if RPMALLOC_FIRST_CLASS_HEAPS
338typedef struct heap_t rpmalloc_heap_t;
365rpmalloc_heap_aligned_alloc(rpmalloc_heap_t *heap,
size_t alignment,
372rpmalloc_heap_calloc(rpmalloc_heap_t *heap,
size_t num,
383rpmalloc_heap_aligned_calloc(rpmalloc_heap_t *heap,
size_t alignment,
391rpmalloc_heap_realloc(rpmalloc_heap_t *heap,
void *ptr,
size_t size,
403 rpmalloc_heap_t *heap,
void *ptr,
size_t alignment,
size_t size,
409RPMALLOC_EXPORT void rpmalloc_heap_free(rpmalloc_heap_t *heap,
void *ptr);
419RPMALLOC_EXPORT void rpmalloc_heap_thread_set_current(rpmalloc_heap_t *heap);
dot regions Print regions of function to dot file(with no function bodies)"
RPMALLOC_EXPORT void rpmalloc_thread_finalize(int release_caches)
Finalize allocator for calling thread.
RPMALLOC_EXPORT void rpmalloc_finalize(void)
Finalize allocator.
RPMALLOC_EXPORT int rpmalloc_initialize_config(const rpmalloc_config_t *config)
Initialize allocator with given configuration.
RPMALLOC_EXPORT void rpmalloc_global_statistics(rpmalloc_global_statistics_t *stats)
Get global statistics.
RPMALLOC_EXPORT int rpmalloc_initialize(void)
Initialize allocator with default configuration.
RPMALLOC_EXPORT void rpmalloc_thread_statistics(rpmalloc_thread_statistics_t *stats)
Get per-thread statistics.
RPMALLOC_EXPORT RPMALLOC_ALLOCATOR void * rpaligned_realloc(void *ptr, size_t alignment, size_t size, size_t oldsize, unsigned int flags) RPMALLOC_ATTRIB_MALLOC RPMALLOC_ATTRIB_ALLOC_SIZE(3)
Reallocate the given block to at least the given size and alignment,.
RPMALLOC_EXPORT void rpmalloc_dump_statistics(void *file)
Dump all statistics in human readable format to file (should be a FILE*)
RPMALLOC_EXPORT int rpposix_memalign(void **memptr, size_t alignment, size_t size)
Allocate a memory block of at least the given size and alignment.
RPMALLOC_EXPORT void rpmalloc_thread_initialize(void)
Initialize allocator for calling thread.
RPMALLOC_EXPORT size_t rpmalloc_usable_size(void *ptr)
Query the usable size of the given memory block (from given pointer to the end of block)
RPMALLOC_EXPORT void rpmalloc_linker_reference(void)
Dummy empty function for forcing linker symbol inclusion.
#define RPMALLOC_ATTRIB_ALLOC_SIZE2(count, size)
RPMALLOC_EXPORT void rpfree(void *ptr)
Free the given memory block.
RPMALLOC_EXPORT int rpmalloc_is_thread_initialized(void)
Query if allocator is initialized for calling thread.
RPMALLOC_EXPORT RPMALLOC_ALLOCATOR void * rpcalloc(size_t num, size_t size) RPMALLOC_ATTRIB_MALLOC RPMALLOC_ATTRIB_ALLOC_SIZE2(1
Allocate a memory block of at least the given size and zero initialize it.
RPMALLOC_EXPORT const rpmalloc_config_t * rpmalloc_config(void)
Get allocator configuration.
#define RPMALLOC_ALLOCATOR
RPMALLOC_EXPORT RPMALLOC_ALLOCATOR void * rpmalloc(size_t size) RPMALLOC_ATTRIB_MALLOC RPMALLOC_ATTRIB_ALLOC_SIZE(1)
Allocate a memory block of at least the given size.
RPMALLOC_EXPORT RPMALLOC_ALLOCATOR void RPMALLOC_EXPORT RPMALLOC_ALLOCATOR void * rpmemalign(size_t alignment, size_t size) RPMALLOC_ATTRIB_MALLOC RPMALLOC_ATTRIB_ALLOC_SIZE(2)
Allocate a memory block of at least the given size and alignment.
#define RPMALLOC_ATTRIB_ALLOC_SIZE(size)
#define RPMALLOC_ATTRIB_MALLOC
RPMALLOC_EXPORT RPMALLOC_ALLOCATOR void * rpaligned_alloc(size_t alignment, size_t size) RPMALLOC_ATTRIB_MALLOC RPMALLOC_ATTRIB_ALLOC_SIZE(2)
Allocate a memory block of at least the given size and alignment.
RPMALLOC_EXPORT RPMALLOC_ALLOCATOR void RPMALLOC_EXPORT RPMALLOC_ALLOCATOR void * rprealloc(void *ptr, size_t size) RPMALLOC_ATTRIB_MALLOC RPMALLOC_ATTRIB_ALLOC_SIZE(2)
Reallocate the given block to at least the given size.
RPMALLOC_EXPORT RPMALLOC_ALLOCATOR void * rpaligned_calloc(size_t alignment, size_t num, size_t size) RPMALLOC_ATTRIB_MALLOC RPMALLOC_ATTRIB_ALLOC_SIZE2(2
Allocate a memory block of at least the given size and alignment, and zero initialize it.
RPMALLOC_EXPORT void rpmalloc_thread_collect(void)
Perform deferred deallocations pending for the calling thread heap.
void(* memory_unmap)(void *address, size_t size, size_t offset, size_t release)
Unmap the memory pages starting at address and spanning the given number of bytes.
int(* map_fail_callback)(size_t size)
Called when a call to map memory pages fails (out of memory).
void(* error_callback)(const char *message)
Called when an assert fails, if asserts are enabled.
size_t span_map_count
Number of spans to map at each request to map new virtual memory blocks.
const char * page_name
Respectively allocated pages and huge allocated pages names for systems.
int enable_huge_pages
Enable use of large/huge pages.
const char * huge_page_name
size_t span_size
Size of a span of memory blocks.
size_t page_size
Size of memory pages.
size_t huge_alloc_peak
Peak amount of memory allocated in huge allocations, i.e larger than LARGE_SIZE_LIMIT which is 2MiB b...
size_t huge_alloc
Current amount of memory allocated in huge allocations, i.e larger than LARGE_SIZE_LIMIT which is 2Mi...
size_t cached
Current amount of memory in global caches for small and medium sizes (<32KiB)
size_t unmapped_total
Total amount of memory unmapped since initialization (only if ENABLE_STATISTICS=1)
size_t mapped
Current amount of virtual memory mapped, all of which might not have been committed (only if ENABLE_S...
size_t mapped_peak
Peak amount of virtual memory mapped, all of which might not have been committed (only if ENABLE_STAT...
size_t mapped_total
Total amount of memory mapped since initialization (only if ENABLE_STATISTICS=1)
size_t from_reserved
Number of spans transitioned from reserved state.
size_t from_global
Number of spans transitioned from global cache.
size_t to_reserved
Number of spans transitioned to reserved state.
size_t spans_to_cache
Number of spans transitioned to cache.
size_t global_to_thread
Total number of bytes transitioned from global cache to thread cache (only if ENABLE_STATISTICS=1)
size_t map_calls
Number of raw memory map calls (not hitting the reserve spans but resulting in actual OS mmap calls)
size_t to_cache
Number of spans transitioned to thread cache.
size_t alloc_total
Total number of allocations.
size_t peak
High water mark of spans used.
struct rpmalloc_thread_statistics_t::@518 span_use[64]
Per span count statistics (only if ENABLE_STATISTICS=1)
size_t spans_from_cache
Number of spans transitioned from cache.
size_t free_total
Total number of frees.
size_t from_cache
Number of spans transitioned from thread cache.
size_t to_global
Number of spans transitioned to global cache.
size_t alloc_current
Current number of allocations.
struct rpmalloc_thread_statistics_t::@519 size_use[128]
Per size class statistics (only if ENABLE_STATISTICS=1)
size_t spans_from_reserved
Number of spans transitioned from reserved state.
size_t current
Currently used number of spans.
size_t alloc_peak
Peak number of allocations.
size_t sizecache
Current number of bytes available in thread size class caches for small and medium sizes (<32KiB)
size_t spancache
Current number of bytes available in thread span caches for small and medium sizes (<32KiB)
size_t thread_to_global
Total number of bytes transitioned from thread cache to global cache (only if ENABLE_STATISTICS=1)