Memory leak?
#1

Is there any problems if I do this?

PHP код:
main()
{
    
CallLocalFunction("func""iii"val1val2val3);
    
// or SetTimerEx("func", 5, false);
}
#include <YSI\y_hooks>
hook func(val1)
{
    
// I do not need val2 and val3 here, so there is just val1 as parameter
    //etc..
    
return 1;

I know it works and it compiles, but can this cause memory leaks / other problems?
Reply
#2

in calling local func u're using3 params, instead of 1 params, or increase params in func()
also if u use SetTimerEx, u need to use params as well
Reply
#3

Well, i know i have 3 arguments and then 1. That's what I ask: can be dangerous if I call a function with more parameters than the public?

Why? look:

PHP код:
SpawnCar(typeFloat:xFloat:yFloat:zFloat:ac1c2respawn=300addsiren=0

    new 
id CreateVehicle(typexyzac1c2respawnaddsiren);
    if(
id != INVALID_VEHICLE_ID)
        
CallLocalFunction("OnVehicleCreate""iiffffiiii"qtypexyzac1c2respawnaddsiren); 
    return 
id
}
// inside vehicle_data.inc
#include <YSI\y_hooks> 
hook OnVehicleCreate(vehicleid
{
    
Vehicle_Fuel[vehicleid] = 0;
    
Players_In_Vehicle[vehicleid] = 0;
    
// i don't need info about vehicle's spawn pos here, so there is just vehicleid as parameter. 
}  
// inside vehicle_mod_and_colors.inc
#include <YSI\y_hooks> 
hook OnVehicleCreate(vehicleidtypeFloat:xFloat:yFloat:zFloat:ac1c2
{
    
Vehicle_Color_1[vehicleid] = c1;
    
Vehicle_Color_2[vehicleid] = c2;
    
// here I need details about colors.

Reply
#4

Yes the code is good.
Reply
#5

You can not call a public function and passing some parameters. Public can not have default parameters and make you pass them. Hooking a function is calling this function. When you use a function, you need to provide every obligatory parameters.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)