Skip to content

Commit 5d531b3

Browse files
Fix: Casting malloc
Closes #193 Co-authored-by: Yuri Victorovich <[email protected]>
1 parent 35ed3f9 commit 5d531b3

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

include/stringzilla/stringzilla.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,12 +1805,22 @@ SZ_INTERNAL void _sz_locate_needle_anomalies(sz_cptr_t start, sz_size_t length,
18051805
#if !SZ_AVOID_LIBC
18061806
#include <stdio.h> // `fprintf`
18071807
#include <stdlib.h> // `malloc`, `EXIT_FAILURE`
1808+
1809+
SZ_PUBLIC void *_sz_memory_allocate_default(sz_size_t length, void *handle) {
1810+
sz_unused(handle);
1811+
return malloc(length);
1812+
}
1813+
SZ_PUBLIC void _sz_memory_free_default(sz_ptr_t start, sz_size_t length, void *handle) {
1814+
sz_unused(handle && length);
1815+
free(start);
1816+
}
1817+
18081818
#endif
18091819

18101820
SZ_PUBLIC void sz_memory_allocator_init_default(sz_memory_allocator_t *alloc) {
18111821
#if !SZ_AVOID_LIBC
1812-
alloc->allocate = (sz_memory_allocate_t)malloc;
1813-
alloc->free = (sz_memory_free_t)free;
1822+
alloc->allocate = (sz_memory_allocate_t)_sz_memory_allocate_default;
1823+
alloc->free = (sz_memory_free_t)_sz_memory_free_default;
18141824
#else
18151825
alloc->allocate = (sz_memory_allocate_t)SZ_NULL;
18161826
alloc->free = (sz_memory_free_t)SZ_NULL;

0 commit comments

Comments
 (0)