Something odd...

Posted by Greven on Tue 10 Feb 2004 11:37 PM — 3 posts, 8,523 views.

Canada #0
Maybe I'm just missing something, but here is what I have:
	if (shuttle->name)
		STRFREE(shuttle->name);
	if (shuttle->takeoff_desc)
		DISPOSE(shuttle->takeoff_desc);
	if (shuttle->filename)
		DISPOSE(shuttle->filename);
	if (shuttle->approach_desc)
		DISPOSE(shuttle->approach_desc);
	if (shuttle->land_desc)
		DISPOSE(shuttle->land_desc);
		
	DISPOSE(shuttle);


And yet:
Quote:
(gdb) frame 2
#2 0x08144e4c in destroy_shuttle (shuttle=0x8226358) at shuttle.c:917
917 DISPOSE(shuttle);
(gdb) print *shuttle
$5 = {
prev = 0x0,
next = 0x0,
next_in_room = 0x0,
prev_in_room = 0x0,
in_room = 0x0,
current = 0x0,
current_number = -1,
state = 1,
first_stop = 0x0,
last_stop = 0x0,
type = SHUTTLE_TURBOCAR,
filename = 0x0,
name = 0x8226240 "Test",
delay = 2,
current_delay = 2,
start_room = 2,
end_room = 2,
entrance = 2,
takeoff_desc = 0x0,
land_desc = 0x0,
approach_desc = 0x0
}


Its crashing. Not instantly, but if I repeat creating/destroying it to test, it crashes. I dunno...
Australia Forum Administrator #1
Why some DISPOSE and some STRFREE? Also disposing the memory does not necessarily make the structure not appear in gdb. It just means that sooner or later that piece of memory will be reused elsewhere.

Have you stepped over line 917 - I think it does the command on the line afterwards, not before.
Canada #2
I dunno why some dipsose, some strfree, I didn't write all of the code, but I've changed it since. However, now I can't seem to recreate it. Oh well.