mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-04-14 22:51:50 +03:00
add test for zero-sized alloc and aligned alloc
This commit is contained in:
parent
01e2a38e5a
commit
2b112ea593
3 changed files with 28 additions and 1 deletions
|
|
@ -226,6 +226,7 @@ endif
|
|||
TESTS_INTEGRATION := $(srcroot)test/integration/aligned_alloc.c \
|
||||
$(srcroot)test/integration/allocated.c \
|
||||
$(srcroot)test/integration/extent.c \
|
||||
$(srcroot)test/integration/malloc.c \
|
||||
$(srcroot)test/integration/mallocx.c \
|
||||
$(srcroot)test/integration/MALLOCX_ARENA.c \
|
||||
$(srcroot)test/integration/overflow.c \
|
||||
|
|
|
|||
|
|
@ -138,10 +138,20 @@ TEST_BEGIN(test_alignment_and_size) {
|
|||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_zero_alloc) {
|
||||
void *res = aligned_alloc(8, 0);
|
||||
assert(res);
|
||||
size_t usable = malloc_usable_size(res);
|
||||
assert(usable > 0);
|
||||
free(res);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void) {
|
||||
return test(
|
||||
test_alignment_errors,
|
||||
test_oom_errors,
|
||||
test_alignment_and_size);
|
||||
test_alignment_and_size,
|
||||
test_zero_alloc);
|
||||
}
|
||||
|
|
|
|||
16
test/integration/malloc.c
Normal file
16
test/integration/malloc.c
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#include "test/jemalloc_test.h"
|
||||
|
||||
TEST_BEGIN(test_zero_alloc) {
|
||||
void *res = malloc(0);
|
||||
assert(res);
|
||||
size_t usable = malloc_usable_size(res);
|
||||
assert(usable > 0);
|
||||
free(res);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void) {
|
||||
return test(
|
||||
test_zero_alloc);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue