diff options
author | HASUMI Hitoshi <[email protected]> | 2024-02-27 14:25:22 +0900 |
---|---|---|
committer | git <[email protected]> | 2024-03-04 16:40:23 +0000 |
commit | c4bd6da2988ecdf3e6d00be78e58a4eba6192bed (patch) | |
tree | f5cc0976ae7ff16bac9913f02ec4d32adef41160 /prism/util/pm_string.c | |
parent | 61ea202f8b10060e000f79a936e5e608eacb50ee (diff) |
[ruby/prism] Make alloc interface replaceable
- Add `x` prefix to malloc, calloc, realloc, and free
(eg: malloc -> xmalloc)
- By default, they are replaced with stdlib's functions at build
- You can use custom functions by defining `PRISM_CUSTOM_ALLOCATOR` macro
https://github.com/ruby/prism/commit/7a878af619
Diffstat (limited to 'prism/util/pm_string.c')
-rw-r--r-- | prism/util/pm_string.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/prism/util/pm_string.c b/prism/util/pm_string.c index 4589f1e8c6..fea3f1d2cf 100644 --- a/prism/util/pm_string.c +++ b/prism/util/pm_string.c @@ -166,7 +166,7 @@ pm_string_ensure_owned(pm_string_t *string) { size_t length = pm_string_length(string); const uint8_t *source = pm_string_source(string); - uint8_t *memory = malloc(length); + uint8_t *memory = xmalloc(length); if (!memory) return; pm_string_owned_init(string, memory, length); @@ -217,7 +217,7 @@ pm_string_free(pm_string_t *string) { void *memory = (void *) string->source; if (string->type == PM_STRING_OWNED) { - free(memory); + xfree(memory); #ifdef PRISM_HAS_MMAP } else if (string->type == PM_STRING_MAPPED && string->length) { #if defined(_WIN32) |