Dmitrii Maganov 4 роки тому
батько
коміт
4c4de37d49
3 змінених файлів з 12 додано та 0 видалено
  1. 7 0
      src/gc.c
  2. 1 0
      src/main.c
  3. 4 0
      src/module.c

+ 7 - 0
src/gc.c

@@ -762,6 +762,12 @@ static void hl_gc_init() {
 #	endif
 }
 
+static void hl_gc_free() {
+#	ifdef HL_THREADS
+	hl_remove_root(&gc_threads.global_lock);
+#	endif
+}
+
 // ---- UTILITIES ----------------------
 
 HL_API bool hl_is_blocking() {
@@ -806,6 +812,7 @@ void hl_global_init() {
 
 void hl_global_free() {
 	hl_cache_free();
+	hl_gc_free();
 }
 
 struct hl_alloc_block {

+ 1 - 0
src/main.c

@@ -244,6 +244,7 @@ int main(int argc, pchar *argv[]) {
 	}
 	hl_module_free(ctx.m);
 	hl_free(&ctx.code->alloc);
+	hl_unregister_thread();
 	hl_global_free();
 	return 0;
 }

+ 4 - 0
src/module.c

@@ -753,6 +753,10 @@ h_bool hl_module_patch( hl_module *m1, hl_code *c ) {
 }
 
 void hl_module_free( hl_module *m ) {
+	for(int i=0;i<m->code->nglobals;i++) {
+		if( hl_is_ptr(m->code->globals[i]) )
+			hl_remove_root(m->globals_data+m->globals_indexes[i]);
+	}
 	hl_free(&m->ctx.alloc);
 	hl_free_executable_memory(m->code, m->codesize);
 	if( m->hash ) hl_code_hash_free(m->hash);