void dgraph_add_edge(struct dgraph_node *from, struct dgraph_node *to) { struct dgraph_edge *e = malloc(sizeof(*e)); e->n[DGRAPH_FROM] = from; e->n[DGRAPH_TO] = to; tlist_add(&from->edge[DGRAPH_FROM], e, list[DGRAPH_FROM]); tlist_add(&to->edge[DGRAPH_TO], e, list[DGRAPH_TO]); }
void tracker_init() { int i, v; char *t; pthread_mutex_lock(&tlock); tlist_clear(); for(i = 0; (t = config_vlist_value("trackers", "host_list", i)) != NULL; i++) { tlist_add(t); xfree(t); } if(i == 0) goto done; t = config_value("global", "server_name"); if(server_name == NULL && t == NULL) { log("*** Set global::server_name if you wish to broadcast to trackers"); log("*** No broadcasting to trackers will be done with the current configuration"); goto done; } if(t != NULL) { if(server_name != NULL) xfree(server_name); server_name = t; server_name_l = strlen(server_name); } t = config_value("global", "server_description"); if(server_desc != NULL) { if(t != NULL) { xfree(server_desc); server_desc = NULL; } } else if(t == NULL) t = xstrdup(""); if(server_name == NULL) { server_desc = t; server_desc_l = strlen(server_desc); } if((v = config_int_value("trackers", "update_interval")) < 0) { log("*** trackers::update_interval invalid/unspecified"); } else update_interval = v; if((server_port = config_int_value("global", "port")) < 0) server_port = DEFAULT_HOTLINE_PORT; tracker_thread_spawn(); done: pthread_mutex_unlock(&tlock); }
int main(int argc, char *argv[]) { struct tlist_children children; struct tlist_cousins cousins; struct child child = { "child" }; struct cousin cousin = { "cousin" }; tlist_init(&children); tlist_init(&cousins); tlist_add(&children, &child, list); tlist_add(&cousins, &cousin, list); tlist_del_from(&cousins, &cousin, list); #ifdef FAIL #if !HAVE_FLEXIBLE_ARRAY_MEMBER #error Need flexible array members to check type #endif tlist_add_tail(&children, &cousin, list); #endif return 0; }
int main(int argc, char *argv[]) { struct tlist_children children; struct child child = { "child" }; #ifdef FAIL #if !HAVE_FLEXIBLE_ARRAY_MEMBER #error Need flexible array members to check type #endif struct cousin *p; #else struct child *p; #endif tlist_init(&children); tlist_add(&children, &child, list); p = tlist_next(&children, &child, list); (void) p; return 0; }
int main(int argc, char *argv[]) { struct tlist_children children; struct child child = { "child" }; #ifdef FAIL #if !HAVE_FLEXIBLE_ARRAY_MEMBER #error Need flexible array members to check type #endif struct cousin *c; #else struct child *c; #endif tlist_init(&children); tlist_add(&children, &child, list); tlist_for_each(&children, c, list) (void) c; /* Suppress unused-but-set-variable warning. */ return 0; }