69,371
社区成员
发帖
与我相关
我的任务
分享
static server *server_init(void) {
int i;
FILE *frandom = NULL;
server *srv = calloc(1, sizeof(*srv));
assert(srv);
#define CLEAN(x) \
srv->x = buffer_init();
CLEAN(response_header);
CLEAN(parse_full_path);
CLEAN(ts_debug_str);
CLEAN(ts_date_str);
CLEAN(errorlog_buf);
CLEAN(response_range);
CLEAN(tmp_buf);
srv->empty_string = buffer_init_string("");
CLEAN(cond_check_buf);
CLEAN(srvconf.errorlog_file);
CLEAN(srvconf.groupname);
CLEAN(srvconf.username);
CLEAN(srvconf.changeroot);
CLEAN(srvconf.bindhost);
CLEAN(srvconf.event_handler);
CLEAN(srvconf.pid_file);
CLEAN(tmp_chunk_len);
#undef CLEAN
#define CLEAN(x) \
srv->x = array_init();
CLEAN(config_context);
CLEAN(config_touched);
CLEAN(status);
#undef CLEAN
/*后面还有*/
}/*main 结束*/
......
static server *server_init(void) {
int i;
FILE *frandom = NULL;
server *srv = calloc(1, sizeof(*srv));
assert(srv);
#define CLEAN(x) srv->x = buffer_init();
CLEAN(response_header); //等价于srv->response_header = buffer_init();
CLEAN(parse_full_path);
CLEAN(ts_debug_str);
CLEAN(ts_date_str);
CLEAN(errorlog_buf);
CLEAN(response_range);
CLEAN(tmp_buf);
srv->empty_string = buffer_init_string("");
CLEAN(cond_check_buf);
CLEAN(srvconf.errorlog_file);
CLEAN(srvconf.groupname);
CLEAN(srvconf.username);
CLEAN(srvconf.changeroot);
CLEAN(srvconf.bindhost);
CLEAN(srvconf.event_handler);
CLEAN(srvconf.pid_file);
CLEAN(tmp_chunk_len);
#undef CLEAN //原来的#define CLEAN(x) srv->x = buffer_init();到这里失效
#define CLEAN(x) srv->x = array_init();
CLEAN(config_context); //等价于srv-> config_context= array_init();
CLEAN(config_touched);
CLEAN(status);
#undef CLEAN //原来的#define CLEAN(x) srv->x = array_init();到这里失效