Well that's part of stock rom.  The reason it works is because
extract_obj() doesn't actually free the memory - it simply recycles it so
that it can be used again later.  It never sets any of the pointers inside
that object to null, nor does it ever invoke free().

So the call to create_object() is still valid, as the object still exists,
and still has pointers to all the right places in memory. Since we are
never actually freeing the data, all we actually did was pull the object
out of the list and stuff it in a "recycle bin" until we need it.

Ideally, you could "clean" out the object, but that is wasted processor
cycles, as the next time you go to reuse that chunk of memory, you'll fill
it in with new things.

> How exactly does this work?
>
>                     if (make_new)
>                     {
>                         int wear;
>
>                         wear = obj->wear_loc;
>                         extract_obj(obj);
>
>                         obj = create_object(obj->pIndexData,0);
>                         obj->wear_loc = wear;
>                     }
>
> if you extract_obj(obj), then how can you
> create_object(obj->pIndexData,0)?  obj would be NULL, and pIndexData
> wouldn't exist, and if for some reason obj weren't NULL, if pIndexData
> were NULL it would cause an exit() within create_object... That looked
> like the only part that might've applied to my situation, as the only
> other part that wasn't stock was the inclusion of this:
>
>                         if ( ch && ch != NULL )
>                             obj_to_char( obj, ch );
>                         else
>                             obj_to_room( obj,
> get_room_index(ROOM_VNUM_LIMBO) );
>
> ... and you can probably get rid of that double ch check, when you say
> if ( ch && ch != NULL ), what you're saying is that if ch has a value
> (hence, != NULL) and ch != NULL (which you just checked)... still open
> for suggestions tho :)
>
> Richard Lindsey.
>
> --
> ROM mailing list
> [email protected]
> http://www.rom.org/cgi-bin/mailman/listinfo/rom
>


Reply via email to