From 2bc94ea66ff4a81bebb6bfe1e84f146c3044f419 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 6 Jun 2001 18:10:47 +0000 Subject: [PATCH] progs.h: add no_exec_limit field. Set to 1 to disable the runaway loop check for unlimited runs (eg, in qwaq) pr_exec.c: don't bother checking the profile counter if pr->no_exec_limit is set pr_strings.c: free unreferenced dynamic strings rather than referenced. --- include/QF/progs.h | 2 ++ libs/gamecode/pr_exec.c | 5 ++--- libs/gamecode/pr_strings.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/QF/progs.h b/include/QF/progs.h index 8b058c027..54b16f8ea 100644 --- a/include/QF/progs.h +++ b/include/QF/progs.h @@ -168,6 +168,7 @@ eval_t *GetEdictFieldValue(progs_t *pr, edict_t *ed, char *field); char *PR_GetString(progs_t *pr, int num); int PR_SetString(progs_t *pr, char *s); +void PR_GarbageCollect (progs_t *pr); //============================================================================ @@ -228,6 +229,7 @@ struct progs_s { int *reserved_edicts; //alloc will start at reserved_edicts+1 double *time; int null_bad; + int no_exec_limit; unsigned short crc; diff --git a/libs/gamecode/pr_exec.c b/libs/gamecode/pr_exec.c index aa62078f4..8297b6fad 100644 --- a/libs/gamecode/pr_exec.c +++ b/libs/gamecode/pr_exec.c @@ -379,9 +379,8 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum) while (1) { st++; - if (++profile > 1000000) // LordHavoc: increased runaway loop - // limit 10x - { + if (!pr->no_exec_limit + && ++profile > 1000000) { pr->pr_xstatement = st - pr->pr_statements; PR_RunError (pr, "runaway loop error"); } diff --git a/libs/gamecode/pr_strings.c b/libs/gamecode/pr_strings.c index 9a1e9ce37..420944424 100644 --- a/libs/gamecode/pr_strings.c +++ b/libs/gamecode/pr_strings.c @@ -130,7 +130,7 @@ PR_GarbageCollect (progs_t *pr) } } for (sr = pr->dynamic_strings.next; sr; sr = sr->next) { - if (sr->count) { + if (!sr->count) { Hash_Del (pr->strref_hash, sr->string); strref_free (sr, pr); }