Commit e8eca379 authored by Kirill Smelkov's avatar Kirill Smelkov

bigfile/test/test_ram: Don't forget to free allocated Page structs

test_ram is low-level test that tests RAM pages allocation/mmapping.
As allocated pages are not integrated with virtmem (not added to any
file mapping and RAM->lru_list) the Page structs have to be explicitly
freed. Fixes e.g.

	Direct leak of 80 byte(s) in 1 object(s) allocated from:
	    #0 0x7ff29af46518 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
	    #1 0x56131dc22289 in zalloc include/wendelin/utils.h:67
	    #2 0x56131dc225d6 in ramh_alloc_page bigfile/tests/../ram.c:41
	    #3 0x56131dc2a19e in main bigfile/tests/test_ram.c:130
	    #4 0x7ff29ac9f09a in __libc_start_main ../csu/libc-start.c:308
parent f688a31d
......@@ -116,6 +116,10 @@ int main()
xmunmap(p01, ps);
xmunmap(p02, ps);
xmunmap(p03, ps);
free(page0);
// page1: was not yet allocated
free(page2);
// page3: was not yet allocated
/* ensure we get "no memory" when overallocating (not doing so would lead
......@@ -145,6 +149,13 @@ int main()
// TODO allocate memory amount = 2*ram_maxsize and touch it linearly
xmunmap(p0, ps);
xmunmap(p1, ps);
xmunmap(p2, ps);
free(page0);
free(page1);
free(page2);
ok1(!page3);
ramh_close(ramh);
ram_close(ram);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment