List test = NULL;
one(&test);
test
is a pointer to struct node
. We pass the address of that
pointer to one
, allowing one
to change test
(letting it return a
new pointer is a cleaner way to do this).
one
then executes this:
two(&self);
two
is now being passed the address of the address of test
. This is
probably not what you intended. Passing the address of test
still lets
you change test
if that’s what you want to do:
two(self);
1
solved Passing a struct pointer containing NULL all of a sudden contains a struct instead of NULL