Memory leakage - case 1: a (simple) memory leak test case. See the following code snippet:
static const size_t BLK_1MB = 1024*1024;[...]static void amleaky(size_t mem){ char *ptr; ptr = malloc(mem); if (!ptr) FATAL("malloc(%zu) failed\n", mem); /* Do something with the memory region; else, the compiler * might just optimize the whole thing away! * ... and we won't 'see' the leak. */ memset(ptr, 0, mem); /* Bug: no free, leakage */}[...]/* test case 11 : memory leak test case 1: simple leak */static void leakage_case1(size_t size){ printf("%s(): will now leak %zu bytes (%ld MB)\n", __FUNCTION__, size, size/(1024*1024)); amleaky(size);}[...] case 11: leakage_case1(32); leakage_case1(BLK_1MB); break;[...]
As one can clearly see, ...