mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2025-05-02 06:16:24 -04:00
add large array growth test
This commit is contained in:
parent
ae4142c2d1
commit
2ae0ed4674
2 changed files with 19 additions and 1 deletions
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…
Add table
Add a link
Reference in a new issue