make a local copy of the builtins table being register as it might need to

be modified
This commit is contained in:
Bill Currie 2004-01-07 02:48:11 +00:00
parent 187cef1d28
commit 7885d9ce25

View file

@ -93,6 +93,7 @@ void
PR_RegisterBuiltins (progs_t *pr, builtin_t *builtins)
{
builtin_t *bi;
int count;
if (!pr->builtin_hash) {
pr->builtin_hash = Hash_NewTable (1021, builtin_get_key, 0, pr);
@ -101,6 +102,13 @@ PR_RegisterBuiltins (progs_t *pr, builtin_t *builtins)
builtin_compare);
}
// count = 1 for terminator
for (bi = builtins, count = 1; bi->name; bi++)
count++;
bi = malloc (count * sizeof (builtin_t));
memcpy (bi, builtins, count * sizeof (builtin_t));
builtins = bi;
while (builtins->name) {
if (builtins->binum == 0 || builtins->binum >= PR_AUTOBUILTIN)
PR_Error (pr, "bad builtin number: %s = #%d", builtins->name,