int main(int argc, char **argv) { unsigned long k; struct test_data *td; t_set_colors(0); t_start("fanout tests"); run_tests(10, 64); run_tests(512, 64); run_tests(64, 64); run_tests(511, 17); destroyed = 0; fot = fanout_create(512); ok_int(fanout_remove(fot, 12398) == NULL, 1, "remove on empty table must yield NULL"); ok_int(fanout_get(fot, 123887987) == NULL, 1, "get on empty table must yield NULL"); for (k = 0; k < 16385; k++) { struct test_data *tdata = calloc(1, sizeof(*td)); tdata->key = k; asprintf(&tdata->name, "%lu", k); fanout_add(fot, k, tdata); } td = fanout_get(fot, k - 1); ok_int(td != NULL, 1, "get must get what add inserts"); ok_int(fanout_remove(fot, k + 1) == NULL, 1, "remove on non-inserted key must yield NULL"); ok_int(fanout_get(fot, k + 1) == NULL, 1, "get on non-inserted must yield NULL"); fanout_destroy(fot, pdest); ok_int((int)destroyed, (int)k, "destroy counter while free()'ing"); return t_end(); }
/* finds a specific downtime entry */ scheduled_downtime *find_downtime(int type, unsigned long downtime_id) { scheduled_downtime *dt = NULL; log_debug_info(DEBUGL_FUNCTIONS, 0, "find_downtime()\n"); dt = fanout_get(dt_fanout, downtime_id); if (dt && (type == ANY_DOWNTIME || type == dt->type)) return dt; return NULL; }