mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-08 04:18:42 +03:00
simplify primitives API
This commit is contained in:
parent
8fbe7aae50
commit
99c9f55511
5 changed files with 83 additions and 58 deletions
|
@ -11,6 +11,7 @@ terms of the MIT license. A copy of the license can be found in the file
|
|||
// note: on all primitive functions, we always get:
|
||||
// addr != NULL and page aligned
|
||||
// size > 0 and page aligned
|
||||
// return value is an error code an int where 0 is success.
|
||||
|
||||
// OS memory configuration
|
||||
typedef struct mi_os_mem_config_s {
|
||||
|
@ -25,13 +26,13 @@ typedef struct mi_os_mem_config_s {
|
|||
void _mi_prim_mem_init( mi_os_mem_config_t* config );
|
||||
|
||||
// Free OS memory
|
||||
void _mi_prim_free(void* addr, size_t size );
|
||||
int _mi_prim_free(void* addr, size_t size );
|
||||
|
||||
// Allocate OS memory. Return NULL on error.
|
||||
// The `try_alignment` is just a hint and the returned pointer does not have to be aligned.
|
||||
// pre: !commit => !allow_large
|
||||
// try_alignment >= _mi_os_page_size() and a power of 2
|
||||
void* _mi_prim_alloc(size_t size, size_t try_alignment, bool commit, bool allow_large, bool* is_large);
|
||||
int _mi_prim_alloc(size_t size, size_t try_alignment, bool commit, bool allow_large, bool* is_large, void** addr);
|
||||
|
||||
// Commit memory. Returns error code or 0 on success.
|
||||
int _mi_prim_commit(void* addr, size_t size, bool commit);
|
||||
|
@ -47,7 +48,7 @@ int _mi_prim_protect(void* addr, size_t size, bool protect);
|
|||
// pre: size > 0 and a multiple of 1GiB.
|
||||
// addr is either NULL or an address hint.
|
||||
// numa_node is either negative (don't care), or a numa node number.
|
||||
void* _mi_prim_alloc_huge_os_pages(void* addr, size_t size, int numa_node);
|
||||
int _mi_prim_alloc_huge_os_pages(void* hint_addr, size_t size, int numa_node, void** addr);
|
||||
|
||||
// Return the current NUMA node
|
||||
size_t _mi_prim_numa_node(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue