LiVES  3.2.0
Data Structures | Macros | Functions
rpmalloc.h File Reference
#include <stddef.h>

Go to the source code of this file.

Data Structures

struct  rpmalloc_global_statistics_t
 
struct  rpmalloc_thread_statistics_t
 
struct  rpmalloc_config_t
 

Macros

#define RPMALLOC_EXPORT
 
#define RPMALLOC_ALLOCATOR
 
#define RPMALLOC_ATTRIB_MALLOC
 
#define RPMALLOC_ATTRIB_ALLOC_SIZE(size)
 
#define RPMALLOC_ATTRIB_ALLOC_SIZE2(count, size)
 
#define RPMALLOC_CDECL
 
#define RPMALLOC_CONFIGURABLE   0
 Define RPMALLOC_CONFIGURABLE to enable configuring sizes. Will introduce. More...
 
#define RPMALLOC_FIRST_CLASS_HEAPS   0
 Define RPMALLOC_FIRST_CLASS_HEAPS to enable heap based API (rpmalloc_heap_* functions). More...
 
#define RPMALLOC_NO_PRESERVE   1
 Flag to rpaligned_realloc to not preserve content in reallocation. More...
 
#define RPMALLOC_GROW_OR_FAIL   2
 Flag to rpaligned_realloc to fail and return null pointer if grow cannot be done in-place,. More...
 

Functions

RPMALLOC_EXPORT int rpmalloc_initialize (void)
 Initialize allocator with default configuration. More...
 
RPMALLOC_EXPORT int rpmalloc_initialize_config (const rpmalloc_config_t *config)
 Initialize allocator with given configuration. More...
 
RPMALLOC_EXPORT const rpmalloc_config_trpmalloc_config (void)
 Get allocator configuration. More...
 
RPMALLOC_EXPORT void rpmalloc_finalize (void)
 Finalize allocator. More...
 
RPMALLOC_EXPORT void rpmalloc_thread_initialize (void)
 Initialize allocator for calling thread. More...
 
RPMALLOC_EXPORT void rpmalloc_thread_finalize (void)
 Finalize allocator for calling thread. More...
 
RPMALLOC_EXPORT void rpmalloc_thread_collect (void)
 Perform deferred deallocations pending for the calling thread heap. More...
 
RPMALLOC_EXPORT int rpmalloc_is_thread_initialized (void)
 Query if allocator is initialized for calling thread. More...
 
RPMALLOC_EXPORT void rpmalloc_thread_statistics (rpmalloc_thread_statistics_t *stats)
 Get per-thread statistics. More...
 
RPMALLOC_EXPORT void rpmalloc_global_statistics (rpmalloc_global_statistics_t *stats)
 Get global statistics. More...
 
RPMALLOC_EXPORT void rpmalloc_dump_statistics (void *file)
 Dump all statistics in human readable format to file (should be a FILE*) More...
 
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. More...
 
RPMALLOC_EXPORT void rpfree (void *ptr)
 Free the given memory block. More...
 
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. More...
 
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. More...
 
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,. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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) More...
 

Macro Definition Documentation

◆ RPMALLOC_ALLOCATOR

#define RPMALLOC_ALLOCATOR

Definition at line 42 of file rpmalloc.h.

◆ RPMALLOC_ATTRIB_ALLOC_SIZE

#define RPMALLOC_ATTRIB_ALLOC_SIZE (   size)

Definition at line 44 of file rpmalloc.h.

◆ RPMALLOC_ATTRIB_ALLOC_SIZE2

#define RPMALLOC_ATTRIB_ALLOC_SIZE2 (   count,
  size 
)

Definition at line 45 of file rpmalloc.h.

◆ RPMALLOC_ATTRIB_MALLOC

#define RPMALLOC_ATTRIB_MALLOC

Definition at line 43 of file rpmalloc.h.

◆ RPMALLOC_CDECL

#define RPMALLOC_CDECL

Definition at line 46 of file rpmalloc.h.

◆ RPMALLOC_CONFIGURABLE

#define RPMALLOC_CONFIGURABLE   0

Define RPMALLOC_CONFIGURABLE to enable configuring sizes. Will introduce.

Definition at line 52 of file rpmalloc.h.

◆ RPMALLOC_EXPORT

#define RPMALLOC_EXPORT

Definition at line 41 of file rpmalloc.h.

◆ RPMALLOC_FIRST_CLASS_HEAPS

#define RPMALLOC_FIRST_CLASS_HEAPS   0

Define RPMALLOC_FIRST_CLASS_HEAPS to enable heap based API (rpmalloc_heap_* functions).

Definition at line 58 of file rpmalloc.h.

◆ RPMALLOC_GROW_OR_FAIL

#define RPMALLOC_GROW_OR_FAIL   2

Flag to rpaligned_realloc to fail and return null pointer if grow cannot be done in-place,.

Definition at line 66 of file rpmalloc.h.

◆ RPMALLOC_NO_PRESERVE

#define RPMALLOC_NO_PRESERVE   1

Flag to rpaligned_realloc to not preserve content in reallocation.

Definition at line 62 of file rpmalloc.h.

Function Documentation

◆ rpaligned_alloc()

RPMALLOC_EXPORT RPMALLOC_ALLOCATOR void* rpaligned_alloc ( size_t  alignment,
size_t  size 
)

Allocate a memory block of at least the given size and alignment.

Definition at line 2669 of file rpmalloc.c.

Referenced by rpaligned_calloc(), rpmemalign(), and rpposix_memalign().

◆ rpaligned_calloc()

RPMALLOC_EXPORT RPMALLOC_ALLOCATOR void* rpaligned_calloc ( size_t  alignment,
size_t  num,
size_t  size 
)

Allocate a memory block of at least the given size and alignment, and zero initialize it.

◆ rpaligned_realloc()

RPMALLOC_EXPORT RPMALLOC_ALLOCATOR void* rpaligned_realloc ( void *  ptr,
size_t  alignment,
size_t  size,
size_t  oldsize,
unsigned int  flags 
)

Reallocate the given block to at least the given size and alignment,.

Definition at line 2656 of file rpmalloc.c.

◆ rpcalloc()

RPMALLOC_EXPORT RPMALLOC_ALLOCATOR void* rpcalloc ( size_t  num,
size_t  size 
)

Allocate a memory block of at least the given size and zero initialize it.

◆ rpfree()

RPMALLOC_EXPORT void rpfree ( void *  ptr)
inline

Free the given memory block.

Definition at line 2612 of file rpmalloc.c.

Referenced by _ext_free(), and quick_free().

◆ rpmalloc()

RPMALLOC_EXPORT RPMALLOC_ALLOCATOR void* rpmalloc ( size_t  size)
inline

Allocate a memory block of at least the given size.

Definition at line 2600 of file rpmalloc.c.

Referenced by _ext_malloc().

◆ rpmalloc_config()

RPMALLOC_EXPORT const rpmalloc_config_t* rpmalloc_config ( void  )

Get allocator configuration.

Definition at line 2593 of file rpmalloc.c.

◆ rpmalloc_dump_statistics()

RPMALLOC_EXPORT void rpmalloc_dump_statistics ( void *  file)

Dump all statistics in human readable format to file (should be a FILE*)

Definition at line 2861 of file rpmalloc.c.

◆ rpmalloc_finalize()

RPMALLOC_EXPORT void rpmalloc_finalize ( void  )

Finalize allocator.

Finalize allocator.

Definition at line 2522 of file rpmalloc.c.

◆ rpmalloc_global_statistics()

RPMALLOC_EXPORT void rpmalloc_global_statistics ( rpmalloc_global_statistics_t stats)

Get global statistics.

Definition at line 2787 of file rpmalloc.c.

◆ rpmalloc_initialize()

RPMALLOC_EXPORT int rpmalloc_initialize ( void  )
inline

Initialize allocator with default configuration.

Initialize allocator with default configuration.

Definition at line 2318 of file rpmalloc.c.

Referenced by init_memfuncs().

◆ rpmalloc_initialize_config()

RPMALLOC_EXPORT int rpmalloc_initialize_config ( const rpmalloc_config_t config)

Initialize allocator with given configuration.

Definition at line 2327 of file rpmalloc.c.

◆ rpmalloc_is_thread_initialized()

RPMALLOC_EXPORT int rpmalloc_is_thread_initialized ( void  )

Query if allocator is initialized for calling thread.

Definition at line 2588 of file rpmalloc.c.

◆ rpmalloc_thread_collect()

RPMALLOC_EXPORT void rpmalloc_thread_collect ( void  )
inline

Perform deferred deallocations pending for the calling thread heap.

Definition at line 2720 of file rpmalloc.c.

◆ rpmalloc_thread_finalize()

RPMALLOC_EXPORT void rpmalloc_thread_finalize ( void  )

Finalize allocator for calling thread.

Finalize allocator for calling thread.

Definition at line 2577 of file rpmalloc.c.

Referenced by rpmalloc_finalize().

◆ rpmalloc_thread_initialize()

RPMALLOC_EXPORT void rpmalloc_thread_initialize ( void  )
inline

Initialize allocator for calling thread.

Initialize allocator for calling thread.

Definition at line 2562 of file rpmalloc.c.

Referenced by init_thread_memfuncs().

◆ rpmalloc_thread_statistics()

RPMALLOC_EXPORT void rpmalloc_thread_statistics ( rpmalloc_thread_statistics_t stats)

Get per-thread statistics.

Definition at line 2724 of file rpmalloc.c.

◆ rpmalloc_usable_size()

RPMALLOC_EXPORT size_t rpmalloc_usable_size ( void *  ptr)
inline

Query the usable size of the given memory block (from given pointer to the end of block)

Definition at line 2715 of file rpmalloc.c.

◆ rpmemalign()

RPMALLOC_EXPORT RPMALLOC_ALLOCATOR void RPMALLOC_EXPORT RPMALLOC_ALLOCATOR void* rpmemalign ( size_t  alignment,
size_t  size 
)
inline

Allocate a memory block of at least the given size and alignment.

Definition at line 2701 of file rpmalloc.c.

◆ rpposix_memalign()

RPMALLOC_EXPORT int rpposix_memalign ( void **  memptr,
size_t  alignment,
size_t  size 
)
inline

Allocate a memory block of at least the given size and alignment.

Definition at line 2706 of file rpmalloc.c.

◆ rprealloc()

RPMALLOC_EXPORT RPMALLOC_ALLOCATOR void RPMALLOC_EXPORT RPMALLOC_ALLOCATOR void* rprealloc ( void *  ptr,
size_t  size 
)
inline

Reallocate the given block to at least the given size.

Definition at line 2644 of file rpmalloc.c.

Referenced by _ext_realloc().