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
|
|
|
|
2021-12-18 09:53:58 +08:00
|
|
|
#include "tree_sitter/api.h"
|
|
|
|
|
|
2016-01-15 15:08:42 -08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-10-05 14:02:49 -07:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdbool.h>
|
2016-11-05 21:23:23 -07:00
|
|
|
#include <stdio.h>
|
2016-10-05 14:02:49 -07:00
|
|
|
|
2021-12-24 09:28:23 +08:00
|
|
|
extern void *(*ts_current_malloc)(size_t);
|
|
|
|
|
extern void *(*ts_current_calloc)(size_t, size_t);
|
|
|
|
|
extern void *(*ts_current_realloc)(void *, size_t);
|
|
|
|
|
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
|
|
|
|
|
|
2021-12-18 00:33:49 +08:00
|
|
|
bool ts_toggle_allocation_recording(bool);
|
|
|
|
|
|
2016-01-15 15:08:42 -08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-01-10 15:22:39 -08:00
|
|
|
#endif // TREE_SITTER_ALLOC_H_
|