/* Destroy child windows, freeing allocated memory. 
This function is a helper function for the  */
static void win_destroy_children(struct win_window *win)
/* Destroy child windows, freeing allocated memory. 
This function is a helper function for the  */
static void win_destroy_children(struct win_window *win)
{
	struct win_window *next_sibling;
	struct win_window *child = win->top_child;
	if (child != NULL) {
		do {
			win_destroy_children(child);
			win_handle_event(child, WIN_EVENT_DESTROY, NULL);
			next_sibling = child->next_sibling;
			membag_free(child);
			child = next_sibling;
		} while (child != win->top_child);
		win->top_child = NULL;
	}
}