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-18 09:53:58 +08:00
|
|
|
extern TSAllocator *ts_allocator;
|
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-17 19:53:02 +08:00
|
|
|
#define ts_malloc ts_allocator->malloc
|
2020-10-29 09:23:58 -07:00
|
|
|
#endif
|
|
|
|
|
#ifndef ts_calloc
|
2021-12-17 19:53:02 +08:00
|
|
|
#define ts_calloc ts_allocator->calloc
|
2020-10-29 09:23:58 -07:00
|
|
|
#endif
|
|
|
|
|
#ifndef ts_realloc
|
2021-12-17 19:53:02 +08:00
|
|
|
#define ts_realloc ts_allocator->realloc
|
2020-10-29 09:23:58 -07:00
|
|
|
#endif
|
|
|
|
|
#ifndef ts_free
|
2021-12-17 19:53:02 +08:00
|
|
|
#define ts_free ts_allocator->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_
|