1
0
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:
Andrew Chambers
2021-03-23 23:00:48 +13:00
parent 8ede16dc26
commit f4c9064b79
31 changed files with 172 additions and 130 deletions

View File

@@ -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 */