In my code I have a class named membrane
with a function named exciteMod()
, a function named decide()
and a variable named delta
lets say you have t number of values needed to be stored. then use this:
int *p = (int *) malloc(t*(sizeof(int)+1));
memset(p,0,t*(sizeof(int)+1));
The most likely cause of uninitialized value is that at least one of b->nextU
or b->U
that you are adding to delta_U
is itself uninitialized. That is:
foo = 0;
foo += some_uninitialized_value;
if (foo) // Valgrind warns here
You would like Valgrind to report when foo becomes uninitialized. Unfortunately, doing so produces too many "false positive" warnings to be practical.
You can insert into your loop calls to VALGRIND_CHECK_MEM_IS_DEFINED
(see Valgrind user manual), and Valgrind will signal the exact moment when delta_U
becomes undefined.