Add TSAllocator and ts_set_allocator in api.h

This commit is contained in:
Mingkai Dong 2021-12-18 09:53:58 +08:00
parent b516f96f37
commit 578bf74bf3
3 changed files with 36 additions and 13 deletions

View file

@ -134,10 +134,31 @@ typedef enum {
TSQueryErrorLanguage,
} TSQueryError;
typedef struct {
void *(*malloc)(size_t);
void *(*calloc)(size_t, size_t);
void *(*realloc)(void *, size_t);
void (*free)(void *);
} TSAllocator;
/********************/
/* Section - Parser */
/********************/
/**
* The allocator.
*/
extern TSAllocator *ts_allocator;
/**
* Switch to a new allocator.
*
* Returns the old allocator. The caller needs to take care of any allocated
* memory managed by the old allocator.
*/
TSAllocator *ts_set_allocator(TSAllocator *new_alloc);
/**
* Create a new parser.
*/