Plugin vector variable changes
#6

Quote:
Originally Posted by Fabsch
View Post
Code:
cell *dest = NULL;
amx_GetAddr(amx,params[2],&dest);
int amount_of_nodes = params[1];
RouteID.push_back(IDcounter);
RouteVector.push_back(RouteData(dest,amount_of_nodes,IDcounter));
amx_GetAddr only returns the address to the cell array stored by the interpreter. After your function and the PAWN function(s) that called it return, the array gets freed in most cases, so you cannot just use this reference, but you have to allocate new memory, copy the values there and free the memory when you no longer need it (usually when you remove it from the list).
then how does it come that everything above 43 saves good?
but so.. if I do
cell * paths
paths = dest , it doesn't copy the content of dest to paths? then how would I do it? can I use memcpy?

Why I ask it...
pawn Code:
struct RouteData
{
    cell * Paths;
    int amount_of_nodes;
    int id;
    RouteData(cell *Paths_,int amount_of_nodes_, int id_)
    {
        memcpy(Paths,Paths_,amount_of_nodes);// <- This crashes the server

//edit: this too doesn't work:
        memcpy(&Paths,Paths_,(amount_of_nodes-1));
//end of edit
        //Paths = Paths_;
        amount_of_nodes = amount_of_nodes_;
        id = id_;
    }
};
Reply


Messages In This Thread
Plugin vector variable changes - by Gamer_Z - 28.11.2011, 20:58
Re: Plugin vector variable changes - by Kar - 28.11.2011, 21:15
Re: Plugin vector variable changes - by FireCat - 28.11.2011, 21:27
Re: Plugin vector variable changes - by Gamer_Z - 28.11.2011, 21:28
AW: Plugin vector variable changes - by Fabsch - 29.11.2011, 11:43
Re: AW: Plugin vector variable changes - by Gamer_Z - 29.11.2011, 15:14
AW: Plugin vector variable changes - by Fabsch - 29.11.2011, 16:15
Re: AW: Plugin vector variable changes - by Gamer_Z - 29.11.2011, 16:24
AW: Plugin vector variable changes - by Fabsch - 29.11.2011, 18:08
Re: Plugin vector variable changes - by Gamer_Z - 29.11.2011, 22:29

Forum Jump:


Users browsing this thread: 1 Guest(s)