#include <hawktracer/macros.h>
#include <stddef.h>
Go to the source code of this file.
◆ HT_CREATE_TYPE
#define HT_CREATE_TYPE |
( |
|
Type | ) |
(Type*)ht_alloc(sizeof(Type)) |
Allocates memory for a specific Type.
- Parameters
-
Type | a type of an object to allocate memory for. |
- Returns
- a pointer to allocated memory.
◆ ht_alloc()
HT_API void* ht_alloc |
( |
size_t |
size | ) |
|
Allocates memory using HawkTracer allocator.
- Parameters
-
size | a number of bytes to allocate. |
- Returns
- a pointer to allocated memory.
◆ ht_allocator_set()
Sets a global allocator for HawkTracer library.
The allocator is used for every allocation in the library. The function must be called before ht_init() function call. If custom allocator is not specified, default allocator will be used.
- Parameters
-
func | an allocation function. |
user_data | an opaque pointer passed to the allocator as a last argument. |
◆ ht_free()
HT_API void ht_free |
( |
void * |
ptr | ) |
|
Releases memory allocated by ht_alloc.
- Parameters
-
ptr | a pointer to the memory block to release. |
◆ ht_realloc()
HT_API void* ht_realloc |
( |
void * |
ptr, |
|
|
size_t |
size |
|
) |
| |
Changes the size of the memory block.
- Parameters
-
ptr | a pointer to the memory block. |
size | new size of the memory block. |
- Returns
- a pointer to reallocated memory.
◆ realloc_function
HT_DECLS_BEGIN typedef void*(* realloc_function) (void *ptr, size_t size, void *user_data) |
Callback function for a custom allocator.
HawkTracer requires only one function, which depending on parameter values, performs: alloc, free, and realloc operations.
To allocate memory, ptr
must be NULL. To free memory, size
must be equal to 0. To realloc memory, size
must be greater than 0, and ptr
must not be NULL.
- Parameters
-
ptr | a pointer to a memory block for alloc/realloc/free operations. |
size | a size of memory block to allocate for alloc/realloc operations. |
user_data | an user data specified in ht_allocator_set(). |
- Returns
- a pointer to allocated memory block for alloc/realloc operations.