mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2024-12-30 01:46:16 -05:00
add large array growth test
This commit is contained in:
parent
ae4142c2d1
commit
2ae0ed4674
@ -9,7 +9,8 @@ CPPFLAGS += \
|
||||
|
||||
EXECUTABLES := \
|
||||
offset \
|
||||
mallinfo
|
||||
mallinfo \
|
||||
large_array_growth
|
||||
|
||||
all: $(EXECUTABLES)
|
||||
|
||||
|
17
test/large_array_growth.c
Normal file
17
test/large_array_growth.c
Normal file
@ -0,0 +1,17 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
void *p = NULL;
|
||||
size_t size = 256 * 1024;
|
||||
|
||||
for (unsigned i = 0; i < 20; i++) {
|
||||
p = realloc(p, size);
|
||||
if (!p) {
|
||||
return 1;
|
||||
}
|
||||
memset(p, 'a', size);
|
||||
size = size * 3 / 2;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user