HawkTracer  0.10.0
alloc.h
Go to the documentation of this file.
1 #ifndef HAWKTRACER_ALLOC_H
2 #define HAWKTRACER_ALLOC_H
3 
4 #include <hawktracer/macros.h>
5 
6 #include <stddef.h>
7 
9 
27 typedef void* (*realloc_function)(void* ptr, size_t size, void* user_data);
28 
39 HT_API void ht_allocator_set(realloc_function func, void* user_data);
40 
48 HT_API void* ht_alloc(size_t size);
49 
58 HT_API void* ht_realloc(void* ptr, size_t size);
59 
65 HT_API void ht_free(void* ptr);
66 
74 #define HT_CREATE_TYPE(Type) (Type*)ht_alloc(sizeof(Type))
75 
77 
78 #endif /* HAWKTRACER_ALLOC_H */
#define HT_API
Defines a directive for exporting/importing symbols from DLL.
Definition: macros.h:76
#define HT_DECLS_END
Defines an end of C linkage block.
Definition: macros.h:17
HT_DECLS_BEGIN typedef void *(* realloc_function)(void *ptr, size_t size, void *user_data)
Callback function for a custom allocator.
Definition: alloc.h:27
HT_API void ht_free(void *ptr)
Releases memory allocated by ht_alloc.
HT_API void * ht_alloc(size_t size)
Allocates memory using HawkTracer allocator.
HT_API void ht_allocator_set(realloc_function func, void *user_data)
Sets a global allocator for HawkTracer library.
#define HT_DECLS_BEGIN
Defines a beginning of C linkage block.
Definition: macros.h:16
HT_API void * ht_realloc(void *ptr, size_t size)
Changes the size of the memory block.