mirror of
https://github.com/tree-sitter/tree-sitter.git
synced 2026-09-12 00:16:30 -04:00
The alloc.h header checked for TREE_SITTER_HIDDEN_SYMBOLS, but the
canonical macro name used everywhere else (api.h, render.rs, setup.py)
is TREE_SITTER_HIDE_SYMBOLS. This mismatch meant that defining
TREE_SITTER_HIDE_SYMBOLS (as the Python binding build does) would not
actually hide the allocator symbols in alloc.h.
Fixes tree-sitter/tree-sitter#5625
Signed-off-by: Georges Savoundararadj <savoundg@amazon.com>
(cherry picked from commit 1da46327b3)
42 lines
917 B
C
42 lines
917 B
C
#ifndef TREE_SITTER_ALLOC_H_
|
|
#define TREE_SITTER_ALLOC_H_
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#if defined(TREE_SITTER_HIDE_SYMBOLS) || defined(_WIN32)
|
|
#define TS_PUBLIC
|
|
#else
|
|
#define TS_PUBLIC __attribute__((visibility("default")))
|
|
#endif
|
|
|
|
TS_PUBLIC extern void *(*ts_current_malloc)(size_t size);
|
|
TS_PUBLIC extern void *(*ts_current_calloc)(size_t count, size_t size);
|
|
TS_PUBLIC extern void *(*ts_current_realloc)(void *ptr, size_t size);
|
|
TS_PUBLIC extern void (*ts_current_free)(void *ptr);
|
|
|
|
// Allow clients to override allocation functions
|
|
#ifndef ts_malloc
|
|
#define ts_malloc ts_current_malloc
|
|
#endif
|
|
#ifndef ts_calloc
|
|
#define ts_calloc ts_current_calloc
|
|
#endif
|
|
#ifndef ts_realloc
|
|
#define ts_realloc ts_current_realloc
|
|
#endif
|
|
#ifndef ts_free
|
|
#define ts_free ts_current_free
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // TREE_SITTER_ALLOC_H_
|