summaryrefslogtreecommitdiff
path: root/prism/util/pm_string_list.c
diff options
authorHASUMI Hitoshi <[email protected]>2024-02-27 14:25:22 +0900
committergit <[email protected]>2024-03-04 16:40:23 +0000
commitc4bd6da2988ecdf3e6d00be78e58a4eba6192bed (patch)
treef5cc0976ae7ff16bac9913f02ec4d32adef41160 /prism/util/pm_string_list.c
parent61ea202f8b10060e000f79a936e5e608eacb50ee (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_list.c')
-rw-r--r--prism/util/pm_string_list.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/prism/util/pm_string_list.c b/prism/util/pm_string_list.c
index d49e4ed734..f6c2145987 100644
--- a/prism/util/pm_string_list.c
+++ b/prism/util/pm_string_list.c
@@ -12,7 +12,7 @@ pm_string_list_append(pm_string_list_t *string_list, pm_string_t *string) {
string_list->capacity *= 2;
}
- string_list->strings = realloc(string_list->strings, string_list->capacity * sizeof(pm_string_t));
+ string_list->strings = xrealloc(string_list->strings, string_list->capacity * sizeof(pm_string_t));
if (string_list->strings == NULL) abort();
}
@@ -24,5 +24,5 @@ pm_string_list_append(pm_string_list_t *string_list, pm_string_t *string) {
*/
void
pm_string_list_free(pm_string_list_t *string_list) {
- free(string_list->strings);
+ xfree(string_list->strings);
}