2019-01-10 15:22:39 -08:00
|
|
|
#ifndef TREE_SITTER_ALLOC_H_
|
|
|
|
|
#define TREE_SITTER_ALLOC_H_
|
2016-01-15 15:08:42 -08:00
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-10-05 14:02:49 -07:00
|
|
|
#include <stdbool.h>
|
2016-11-05 21:23:23 -07:00
|
|
|
#include <stdio.h>
|
2024-02-22 09:13:59 -05:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
#define TS_PUBLIC __declspec(dllexport)
|
|
|
|
|
#else
|
|
|
|
|
#define TS_PUBLIC __attribute__((visibility("default")))
|
|
|
|
|
#endif
|
2016-10-05 14:02:49 -07:00
|
|
|
|
2024-02-22 09:13:59 -05:00
|
|
|
TS_PUBLIC extern void *(*ts_current_malloc)(size_t);
|
|
|
|
|
TS_PUBLIC extern void *(*ts_current_calloc)(size_t, size_t);
|
|
|
|
|
TS_PUBLIC extern void *(*ts_current_realloc)(void *, size_t);
|
|
|
|
|
TS_PUBLIC extern void (*ts_current_free)(void *);
|
2016-01-18 10:44:49 -08:00
|
|
|
|
2020-10-29 09:23:58 -07:00
|
|
|
// Allow clients to override allocation functions
|
|
|
|
|
#ifndef ts_malloc
|
2021-12-24 09:28:23 +08:00
|
|
|
#define ts_malloc ts_current_malloc
|
2020-10-29 09:23:58 -07:00
|
|
|
#endif
|
|
|
|
|
#ifndef ts_calloc
|
2021-12-24 09:28:23 +08:00
|
|
|
#define ts_calloc ts_current_calloc
|
2020-10-29 09:23:58 -07:00
|
|
|
#endif
|
|
|
|
|
#ifndef ts_realloc
|
2021-12-24 09:28:23 +08:00
|
|
|
#define ts_realloc ts_current_realloc
|
2020-10-29 09:23:58 -07:00
|
|
|
#endif
|
|
|
|
|
#ifndef ts_free
|
2021-12-24 09:28:23 +08:00
|
|
|
#define ts_free ts_current_free
|
2016-01-18 10:44:49 -08:00
|
|
|
#endif
|
|
|
|
|
|
2016-01-15 15:08:42 -08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-02-22 09:13:59 -05:00
|
|
|
#endif // TREE_SITTER_ALLOC_H_
|