blob: 33249db420fac378ffa2b3b20b1f52ec8426c89f [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/* 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
7int 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}