child.c
来自「CS架构的多平台的GUI系统」· C语言 代码 · 共 92 行
C
92 行
/*************************************************************************** begin : Thu Jun 24 2004 copyright : (C) 2004 - 2005 by Alper Akcan email : distchx@yahoo.com ***************************************************************************//*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or (at your option) any later version. * * * ***************************************************************************/#include "xynth_.h"int s_child_add (s_window_t *window, s_window_t *child){ int ret; s_childs_t *chl = window->childs; s_thread_mutex_lock(chl->mut); ret = s_list_add(chl->list, child, 0); s_thread_mutex_unlock(chl->mut); return ret;}int s_child_del (s_window_t *window, s_window_t *child){ int p = 0; int ret = 1; s_window_t *w; s_childs_t *chl = window->childs; s_thread_mutex_lock(chl->mut); while (!s_list_eol(chl->list, p)) { w = (s_window_t *) s_list_get(chl->list, p); if (w->tid == child->tid) { s_list_remove(chl->list, p); break; } p++; } s_thread_mutex_unlock(chl->mut); return ret;}int s_childs_init (s_window_t *window){ window->childs = (s_childs_t *) s_calloc(1, sizeof(s_childs_t)); window->childs->list = (s_list_t *) s_calloc(1, sizeof(s_list_t)); if (s_thread_mutex_init(&(window->childs->mut))) { goto err0; } return s_list_init(window->childs->list);err0: s_free(window->childs->list); s_free(window->childs); return -1;}int s_childs_uninit (s_window_t *window){ s_thread_t *t; s_window_t *w; s_childs_t *chl = window->childs; while (1) { s_thread_mutex_lock(chl->mut); if (s_list_eol(chl->list, 0)) { s_thread_mutex_unlock(chl->mut); break; } w = (s_window_t *) s_list_get(chl->list, 0); s_list_remove(chl->list, 0); t = w->tid; s_client_quit(w); s_thread_mutex_unlock(chl->mut); s_thread_join(t, NULL); } s_thread_mutex_destroy(chl->mut); s_free(chl->list); s_free(chl); return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?