void gli_stream_close(stream_t *str) { window_t *win; if (str == gli_currentstr) { gli_currentstr = NULL; } for (win = gli_window_fixiterate(NULL); win != NULL; win = gli_window_fixiterate(win)) { if (win->echostr == str) win->echostr = NULL; } switch (str->type) { case strtype_Window: /* nothing necessary; the window is already being closed */ break; case strtype_Memory: if (gli_unregister_arr) { (*gli_unregister_arr)(str->buf, str->buflen, "&+#!Cn", str->arrayrock); } break; case strtype_File: fclose(str->file); str->file = NULL; break; } gli_delete_stream(str); }
void gli_delete_window(window_t *win) { window_t *prev, *next; if (gli_unregister_obj) (*gli_unregister_obj)(win, gidisp_Class_Window, win->disprock); win->magicnum = 0; win->echostr = NULL; if (win->str) { gli_delete_stream(win->str); win->str = NULL; } prev = win->prev; next = win->next; win->prev = NULL; win->next = NULL; if (prev) prev->next = next; else gli_windowlist = next; if (next) next->prev = prev; free(win); }