Why does this happen? : I send a char * to a function and if certain
conditions are true, it is assigned NULL and then returns from that
function, but when I check to see if it's NULL, I find out that it's back
to what it was before!  Why?  Here's the gdb snapshot to show what I am
talking about.

52      ptr = strstr(haystack,needle); <-- This is suppose to return NULL
1: buffer = 0x804aa80 "" <-- What it starts out as
(gdb) next
53      if (ptr == NULL) {
1: buffer = 0x804aa80 ""
(gdb) print ptr
$1 = 0x0
(gdb) next
54              buffer = NULL;
1: buffer = 0x804aa80 ""
(gdb) next
55              return;
1: buffer = 0x0 <-- Right.
(gdb) next
83      } // END FUNCTION
1: buffer = 0x0 <-- Still OK.
(gdb) next
main () at sendmessage.c:177
177     if (buffer == NULL) {
(gdb) print buffer
$2 = 0x804aa80 "" <-- It changes back!
(gdb)


Reply via email to