aboutsummaryrefslogtreecommitdiffstats
path: root/code/qcommon/vm.c
diff options
context:
space:
mode:
Diffstat (limited to 'code/qcommon/vm.c')
-rw-r--r--code/qcommon/vm.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/code/qcommon/vm.c b/code/qcommon/vm.c
index ecc29c1..919f09c 100644
--- a/code/qcommon/vm.c
+++ b/code/qcommon/vm.c
@@ -608,6 +608,15 @@ VM_Free
*/
void VM_Free( vm_t *vm ) {
+ if(!vm) {
+ return;
+ }
+
+ if(vm->callLevel) {
+ Com_Error( ERR_FATAL, "VM_Free(%s) on running vm", vm->name );
+ return;
+ }
+
if(vm->destroy)
vm->destroy(vm);
@@ -635,13 +644,8 @@ void VM_Free( vm_t *vm ) {
void VM_Clear(void) {
int i;
for (i=0;i<MAX_VM; i++) {
- if ( vmTable[i].dllHandle ) {
- Sys_UnloadDll( vmTable[i].dllHandle );
- }
- Com_Memset( &vmTable[i], 0, sizeof( vm_t ) );
+ VM_Free(&vmTable[i]);
}
- currentVM = NULL;
- lastVM = NULL;
}
void *VM_ArgPtr( intptr_t intValue ) {
@@ -722,6 +726,7 @@ intptr_t QDECL VM_Call( vm_t *vm, int callnum, ... ) {
Com_Printf( "VM_Call( %d )\n", callnum );
}
+ ++vm->callLevel;
// if we have a dll loaded, call it directly
if ( vm->entryPoint ) {
//rcg010207 - see dissertation at top of VM_DllSyscall() in this file.
@@ -765,6 +770,7 @@ intptr_t QDECL VM_Call( vm_t *vm, int callnum, ... ) {
r = VM_CallInterpreted( vm, &a.callnum );
#endif
}
+ --vm->callLevel;
if ( oldVM != NULL )
currentVM = oldVM;