add large array growth test
parent
ae4142c2d1
commit
2ae0ed4674
|
@ -9,7 +9,8 @@ CPPFLAGS += \
|
|||
|
||||
EXECUTABLES := \
|
||||
offset \
|
||||
mallinfo
|
||||
mallinfo \
|
||||
large_array_growth
|
||||
|
||||
all: $(EXECUTABLES)
|
||||
|
||||
|
|
|
@ -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