diff --git a/main/gbx/gbx_c_file.c b/main/gbx/gbx_c_file.c index c97cbb021..1fe8d439b 100644 --- a/main/gbx/gbx_c_file.c +++ b/main/gbx/gbx_c_file.c @@ -57,7 +57,7 @@ DECLARE_EVENT(EVENT_Write); static GB_FUNCTION read_func; static char _buffer[16]; - +static bool _do_not_close = FALSE; static void callback_read(int fd, int type, CFILE *file) { @@ -127,9 +127,11 @@ void CFILE_init(void) void CFILE_exit(void) { + _do_not_close = TRUE; GB_Unref(POINTER(&CFILE_in)); GB_Unref(POINTER(&CFILE_out)); GB_Unref(POINTER(&CFILE_err)); + _do_not_close = FALSE; } void CFILE_init_watch(void) @@ -146,7 +148,9 @@ void CFILE_init_watch(void) BEGIN_METHOD_VOID(CFILE_free) - STREAM_close(&THIS->ob.stream); + if (!_do_not_close) + STREAM_close(&THIS->ob.stream); + if (THIS->watch_fd >= 0) GB_Watch(THIS->watch_fd, GB_WATCH_NONE, NULL, 0); diff --git a/main/gbx/gbx_class.c b/main/gbx/gbx_class.c index e7e71b27d..e9e5a1ffa 100644 --- a/main/gbx/gbx_class.c +++ b/main/gbx/gbx_class.c @@ -392,7 +392,7 @@ CLASS *CLASS_find(const char *name) #endif } - ALLOC_ZERO(&class, Max(128, sizeof(CLASS)), "CLASS_find"); + ALLOC_ZERO(&class, sizeof(CLASS), "CLASS_find"); csym->class = class; /*csym->class->id = index;*/ class->state = CS_NULL;