mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-13 08:27:39 +00:00
Copy only the necessary number of vararg parameters
This commit is contained in:
parent
12d2a0ff75
commit
ed283a9e7f
1 changed files with 7 additions and 5 deletions
|
@ -170,7 +170,7 @@ PR_EnterFunction (progs_t *pr, bfunction_t *f)
|
||||||
{
|
{
|
||||||
pr_int_t i;
|
pr_int_t i;
|
||||||
pr_type_t *dstParams[MAX_PARMS];
|
pr_type_t *dstParams[MAX_PARMS];
|
||||||
long paramofs = 0;
|
pointer_t paramofs = 0;
|
||||||
|
|
||||||
PR_PushFrame (pr);
|
PR_PushFrame (pr);
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ PR_EnterFunction (progs_t *pr, bfunction_t *f)
|
||||||
if (i < MAX_PARMS) {
|
if (i < MAX_PARMS) {
|
||||||
dstParams[i] = pr->pr_globals + paramofs;
|
dstParams[i] = pr->pr_globals + paramofs;
|
||||||
}
|
}
|
||||||
for (; i < MAX_PARMS; i++) {
|
for (; i < pr->pr_argc; i++) {
|
||||||
if (pr->pr_params[i] != pr->pr_real_params[i]) {
|
if (pr->pr_params[i] != pr->pr_real_params[i]) {
|
||||||
copy_param (pr->pr_real_params[i], pr->pr_params[i],
|
copy_param (pr->pr_real_params[i], pr->pr_params[i],
|
||||||
parmsize.size);
|
parmsize.size);
|
||||||
|
@ -232,16 +232,18 @@ PR_EnterFunction (progs_t *pr, bfunction_t *f)
|
||||||
copy_param (dstParams[i], pr->pr_params[i], f->parm_size[i].size);
|
copy_param (dstParams[i], pr->pr_params[i], f->parm_size[i].size);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
int copy_args;
|
||||||
pr_type_t *argc = &pr->pr_globals[f->parm_start + 0];
|
pr_type_t *argc = &pr->pr_globals[f->parm_start + 0];
|
||||||
pr_type_t *argv = &pr->pr_globals[f->parm_start + 1];
|
pr_type_t *argv = &pr->pr_globals[f->parm_start + 1];
|
||||||
for (i = 0; i < -f->numparms - 1; i++) {
|
for (i = 0; i < -f->numparms - 1; i++) {
|
||||||
copy_param (dstParams[i], pr->pr_params[i], f->parm_size[i].size);
|
copy_param (dstParams[i], pr->pr_params[i], f->parm_size[i].size);
|
||||||
}
|
}
|
||||||
argc->integer_var = pr->pr_argc - i;
|
copy_args = pr->pr_argc - i;
|
||||||
|
argc->integer_var = copy_args;
|
||||||
argv->integer_var = dstParams[i] - pr->pr_globals;
|
argv->integer_var = dstParams[i] - pr->pr_globals;
|
||||||
if (i < MAX_PARMS) {
|
if (i < MAX_PARMS) {
|
||||||
memcpy (dstParams[i], &P_INT (pr, i),
|
memcpy (dstParams[i], pr->pr_params[i],
|
||||||
(MAX_PARMS - i) * pr->pr_param_size * sizeof (pr_type_t));
|
(copy_args * pr->pr_param_size) * sizeof (pr_type_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue