aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/include/janet.h
diff options
context:
space:
mode:
authorAndrew Chambers <ac@acha.ninja>2021-03-23 23:00:48 +1300
committerAndrew Chambers <ac@acha.ninja>2021-03-23 23:00:48 +1300
commitf4c9064b79d5b32fd74e5ddf25266356c22dd53b (patch)
tree0fb2dc0bafbcfc3e597c13d3df4738cd50be33a3 /src/include/janet.h
parentMerge pull request #669 from dbready/dist_layout (diff)
Add config support for custom allocators.
Diffstat (limited to 'src/include/janet.h')
-rw-r--r--src/include/janet.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/include/janet.h b/src/include/janet.h
index 4448a903..7c37c168 100644
--- a/src/include/janet.h
+++ b/src/include/janet.h
@@ -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 */