MySQL: Storing result but not freeing.
#1

Well I used the mysql_debug(1) function to see what's going on in my script. I noticed that it stored the result even though I don't have anything in that table, but it did not free it, I'm wondering if that could cause a memory leak.

This is what a normal query of mine would look like:

pawn Код:
format(vfile,sizeof(vfile),"SELECT * FROM vehicle2 WHERE Owner = '%s' LIMIT 1",escape);
                    mysql_query(vfile);
                    mysql_store_result();
                    if(mysql_num_rows() != 0)
                    {
                        mysql_free_result();
                        GetVehiclePos(CarSystem[playerid][vID][1],X,Y,Z);
                        GetVehicleZAngle(CarSystem[playerid][vID][1],A);
                        format(String,sizeof(String),"UPDATE vehicle2 SET vModel = %d, XSpawn = %f, YSpawn = %f, ZSpawn = %f, Angle = %f WHERE Owner = '%s'",GetVehicleModel(CarSystem[playerid][vID][1]),X,Y,Z,A,escape);
                        mysql_query(String);
                        format(String,sizeof(String),"UPDATE vehicle2 SET vMod0 = %d,vMod1 = %d,vMod2 = %d,vMod3 = %d,vMod4 = %d,vMod5 = %d,vMod6 = %d,vMod7 = %d,vMod8 = %d,vMod9 = %d,vMod10 = %d,vMod11 = %d,vMod12 = %d WHERE Owner = '%s'",
                        CarSystem[playerid][vMods2][0],CarSystem[playerid][vMods2][1],CarSystem[playerid][vMods2][2],CarSystem[playerid][vMods2][3],CarSystem[playerid][vMods2][4],CarSystem[playerid][vMods2][5],CarSystem[playerid][vMods2][6],CarSystem[playerid][vMods2][7],CarSystem[playerid][vMods2][8],CarSystem[playerid][vMods2][9],CarSystem[playerid][vMods2][10],CarSystem[playerid][vMods2][11],CarSystem[playerid][vMods2][12],escape);
                        mysql_query(String);
                    }
Please ignore the indentation, the forum messed it up -_-
Note: I don't have anything in the 'vehicle2' table. Should I still add 'mysql_free_result even though I don't have it, the result was stored......

If you want to see the log I'll provide it.
Reply
#2

It won't cause a memory leak because there's nothing to store. You can't free an invalid result as I said before, so you're fine.

Also, you should consider posting your questions in the release topic of the plugin you use - people might end up confusing the two major plugins and give you incorrect advice. Plus, I'm subscribed to that thread [or at least G-sTyLeZzZ's release] so I get an email whenever anyone replies to it, so I'm usually quick to help, as well as loads of others.
Reply
#3

Thanks, Calg00ne, and can I add you on MSN just for this issue?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)