Skip to content

Commit

Permalink
* Too many bugs in the code, should fix bugs with pilot hooks when using
Browse files Browse the repository at this point in the history
>1 parameter.
  • Loading branch information
bobbens committed Apr 1, 2015
1 parent 6f4005f commit 3ba9caf
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/pilot_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,26 @@ static int pilot_hookCleanup = 0; /**< Are hooks being removed from a pilot? */
int pilot_runHookParam( Pilot* p, int hook_type, HookParam* param, int nparam )
{
int n, i, run, ret;
HookParam hparam[3], *hdynparam;
HookParam hstaparam[5], *hdynparam, *hparam;

/* Set up hook parameters. */
if (nparam <= 1) {
hparam[0].type = HOOK_PARAM_PILOT;
hparam[0].u.lp.pilot = p->id;
if (nparam <= 3) {
hstaparam[0].type = HOOK_PARAM_PILOT;
hstaparam[0].u.lp.pilot = p->id;
n = 1;
if (nparam == 1) {
memcpy( &hparam[n], param, sizeof(HookParam) );
n++;
}
hparam[n].type = HOOK_PARAM_SENTINEL;
memcpy( &hstaparam[n], param, sizeof(HookParam)*nparam );
n += nparam;
hstaparam[n].type = HOOK_PARAM_SENTINEL;
hdynparam = NULL;
hparam = hstaparam;
}
else {
hdynparam = malloc( sizeof(HookParam) * (nparam+2) );
hdynparam[0].type = HOOK_PARAM_PILOT;
hdynparam[0].u.lp.pilot = p->id;
memcpy( &hdynparam[1], param, sizeof(HookParam)*nparam );
hdynparam[nparam+1].type = HOOK_PARAM_SENTINEL;
hparam = hdynparam;
}

/* Run pilot specific hooks. */
Expand Down

0 comments on commit 3ba9caf

Please sign in to comment.