heap/heap_caps: added initial, top level heap_caps_aligned_alloc and heap_caps_aligned_free

This commit is contained in:
Felipe Neves
2019-11-13 12:49:57 +08:00
parent f31b8a8ab8
commit 7fbf4c74d7
2 changed files with 115 additions and 0 deletions

View File

@@ -85,6 +85,30 @@ void heap_caps_free( void *ptr);
*/
void *heap_caps_realloc( void *ptr, size_t size, int caps);
/**
* @brief Allocate a aligned chunk of memory which has the given capabilities
*
* Equivalent semantics to libc aligned_alloc(), for capability-aware memory.
* @param alignment How the pointer received needs to be aligned
* must be a power of two
* @param size Size, in bytes, of the amount of memory to allocate
* @param caps Bitwise OR of MALLOC_CAP_* flags indicating the type
* of memory to be returned
*
* @return A pointer to the memory allocated on success, NULL on failure
*/
void *heap_caps_aligned_alloc(size_t alignment, size_t size, int caps);
/**
* @brief Used to deallocate memory previously allocated with heap_caps_aligned_alloc
*
* @param ptr Pointer to the memory allocated
* @note This function is aimed to deallocate only memory allocated with
* heap_caps_aligned_alloc, memory allocated with heap_caps_malloc
* MUST not be passed to this function
*/
void heap_caps_aligned_free(void *ptr);
/**
* @brief Allocate a chunk of memory which has the given capabilities. The initialized value in the memory is set to zero.
*