10 Dec
2007
10 Dec
'07
8:57 a.m.
Hi Given a pointer p, dispose(p) does not set p to nil. This program, program tst; type ptr = ^string; var p : ptr; begin p := new( ptr, 20 ); p^ := "abc"; writeln( p^ ); dispose( p ); p := nil; if p = nil then writeln("OK"); dispose( p ); writeln( p^ ); end. as is gives you abc OK segmentation fault The seg fault is from the last writeln. If you comment out the line "p := nil", the second "dispose" causes a core dump. If you comment out both "p := nil" and the second "dispose" you get abc abc and that's also an error. I do not know what side effects you might get if you caused "dispose" to set the pointer to nil. Russ