mirror of
https://github.com/janet-lang/janet
synced 2025-11-07 11:03:04 +00:00
Add config support for custom allocators.
This commit is contained in:
@@ -288,7 +288,6 @@ typedef struct {
|
||||
JANET_CURRENT_CONFIG_BITS })
|
||||
#endif
|
||||
|
||||
|
||||
/***** END SECTION CONFIG *****/
|
||||
|
||||
/***** START SECTION TYPES *****/
|
||||
@@ -1940,6 +1939,24 @@ JANET_API JanetThread *janet_thread_current(void);
|
||||
|
||||
#endif
|
||||
|
||||
/* Custom allocator support */
|
||||
JANET_API void *(janet_malloc)(size_t);
|
||||
JANET_API void *(janet_realloc)(void *, size_t);
|
||||
JANET_API void *(janet_calloc)(size_t, size_t);
|
||||
JANET_API void (janet_free)(void *);
|
||||
#ifndef janet_malloc
|
||||
#define janet_malloc(X) malloc((X))
|
||||
#endif
|
||||
#ifndef janet_realloc
|
||||
#define janet_realloc(X, Y) realloc((X), (Y))
|
||||
#endif
|
||||
#ifndef janet_calloc
|
||||
#define janet_calloc(X, Y) calloc((X), (Y))
|
||||
#endif
|
||||
#ifndef janet_free
|
||||
#define janet_free(X) free((X))
|
||||
#endif
|
||||
|
||||
/***** END SECTION MAIN *****/
|
||||
|
||||
/* Re-enable popped variable length array warnings */
|
||||
|
||||
Reference in New Issue
Block a user