Pointer-related woes (C/C++) - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Pointer-related woes (C/C++) (/thread-4601.html)
Pointer-related woes (C/C++) - sealfin - Jan 18, 2006 10:58 AM
Okay, I've the rather strange situation where an array of pointers will give different addresses for those pointers in two different methods; in a third method, it will give the same address as in the first method (the correct address.)
Between the two method calls, the array is not manipulated in any way.
Any suggestions? I'm being driven insane by this, and Xcode's debugger isn't helping (why won't it show the attributes of a class half the time? )
(I'm trying to share pointers between two objects using private methods to let a child object take the pointers held by a parent object, so that the pointers remain hidden outside of those objects.)
The array is initialised as:
The first method assigns the pointers into the array as:
The second method returns an indexed pointer from the array as:
Pointer-related woes (C/C++) - Fenris - Jan 18, 2006 11:29 AM
Spontaneous response: does Bind() copy the contents of label? Because if not, free (label) will destroy the memory for all of your objects...
Pointer-related woes (C/C++) - sealfin - Jan 18, 2006 01:22 PM
Circumvented the strangeness by returning a pointer to the array itself, rather than returning a pointer held in the array, passing a different index to the method for the entire array Weird when such strangess results in you developing a more elegant solution than the original - I really don't know why I just didn't do that in the first place
@Fenris: Bind() just takes the label as the label of the leaf to look for in the tree; it doesn't make a copy, and shouldn't make a copy - this probably would've been clearer if I hadn't obfuscated the identifiers - maybe I shouldn't in future, but if I hadn't, I think the only reply I'd receive is "wtf?"