Re: Man this is wierd...

From: Johan Eenfeldt (d95joe@csd.uu.se)
Date: 04/14/96


On Sun, 14 Apr 1996, Hades wrote:

> Tell me if this would work:
> struct obj_data *obj, *objtwo;
> 
> obj is assigned some values from somewhere, like read_object
> Will this copy all data from the object over... not the pointer to the objs
> location in memopry but all the actual data:
> *objtwo = *obj;

That should work, IF objtwo is pointing to something valid. (i.e you did 
a CREATE(objtwo, struct obj_data, 1) somewhere in between).
But it does indeed copy the actual data.

> So basically objtwo will be a complete copy of obj, BUT have it's own and
> seperate pointer. Does this work? Or am I thinking completely wrong?

As long as it is pointing to some allocated storage. The pointer will not 
be changed of course.

> And one last thing, the protos are stored in obj_proto. For the linked list
> there is now: struct obj_data *next_proto; in the obj_data in structs.h/
> Nowhere in my code does obj_proto and object_list cross over, yet when
> read_object is called, it trashes my obj_proto list and replaces it with the
> obj loaded.
> 
> Ie. The spell flame blade goes off. Instead of obj_proto pointing to the
> last object loaded into the list, it now points to the flame blade, at the
> END of the list. Nowhere in create_obj or read_objerct does it even mention
> obj_proto.
> 
> Any clues hints or suggestions>?

Well. It does sound like a pointer problem...
Without more information it is a bit hard to tell. Good luck finding it.


/ Johan Eenfeldt
  Student, Computer Science Department @ the University of Uppsala
  d95joe@csd.uu.se



This archive was generated by hypermail 2b30 : 12/18/00 PST