lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | /* make sure that realloc() can properly shrink buffers */ |
2 | |||||
3 | #include <stdlib.h> | ||||
4 | |||||
5 | #define LARGE_BUFFER (1 << 20) /* idea is to span a lot of pages */ | ||||
6 | |||||
7 | int main(int argc, char *argv[]) | ||||
8 | { | ||||
9 | int count = 20; | ||||
10 | char *ptr = NULL; | ||||
11 | while (count--) { | ||||
12 | ptr = realloc(ptr, LARGE_BUFFER); | ||||
13 | ptr = realloc(ptr, 1); | ||||
14 | } | ||||
15 | free(ptr); | ||||
16 | return 0; | ||||
17 | } |