Author: Stan Eisenstat
Subject: Re: [Cs323] failing test 18
Date: Thursday, 29 Oct 2020, 14:26:39
> Message Posted By: Unknown
>
> Test 18 description is that all storage should be reachable. Does that
> just mean we dont free our table at the end? What is the requirement for
> this?
No. It means that:
While heap storage need not be free()-ed before exiting, it must all be
reachable at that time; i.e., valgrind should report 0 bytes lost.
Note: When main() returns, storage for all variables stored on the stack
is freed before valgrind checks for unreachable heap storage. Thus if an
argument or automatic local variable contained the only pointer to a block
on the heap, valgrind will report that block as being unreachable. One
solution is to call exit() instead of returning, so that stack storage is
not freed. Another is to store the pointer in a global or static local
variable (which is not stored on the stack).
--Stan-
PREV
INDEX
NEXT