예제 #1
0
파일: mlrcli.c 프로젝트: jjlu521016/miller
static void free_opt_singletons() {
	lhmss_free(singleton_pdesc_to_chars_map);
	lhmss_free(singleton_default_rses);
	lhmss_free(singleton_default_fses);
	lhmss_free(singleton_default_pses);
	lhmsi_free(singleton_default_repeat_ifses);
	lhmsi_free(singleton_default_repeat_ipses);
}
예제 #2
0
static void stats1_percentile_free(stats1_acc_t* pstats1_acc) {
	stats1_percentile_state_t* pstate = pstats1_acc->pvstate;
	pstate->reference_count--;
	if (pstate->reference_count == 0) {
		percentile_keeper_free(pstate->ppercentile_keeper);
		lhmss_free(pstate->poutput_field_names);
		free(pstate);
		free(pstats1_acc);
	}
}
예제 #3
0
// ----------------------------------------------------------------
static char* test_lhmss() {

	lhmss_t *pmap = lhmss_alloc();
	mu_assert_lf(pmap->num_occupied == 0);
	mu_assert_lf(!lhmss_has_key(pmap, "w")); mu_assert_lf(lhmss_get(pmap, "w") == NULL);
	mu_assert_lf(!lhmss_has_key(pmap, "x")); mu_assert_lf(lhmss_get(pmap, "x") == NULL);
	mu_assert_lf(!lhmss_has_key(pmap, "y")); mu_assert_lf(lhmss_get(pmap, "y") == NULL);
	mu_assert_lf(!lhmss_has_key(pmap, "z")); mu_assert_lf(lhmss_get(pmap, "z") == NULL);
	mu_assert_lf(lhmss_check_counts(pmap));

	lhmss_put(pmap, "x", "3");
	mu_assert_lf(pmap->num_occupied == 1);
	mu_assert_lf(!lhmss_has_key(pmap, "w")); mu_assert_lf(lhmss_get(pmap, "w") == NULL);
	mu_assert_lf( lhmss_has_key(pmap, "x")); mu_assert_lf(streq(lhmss_get(pmap, "x"), "3"));
	mu_assert_lf(!lhmss_has_key(pmap, "y")); mu_assert_lf(lhmss_get(pmap, "y") == NULL);
	mu_assert_lf(!lhmss_has_key(pmap, "z")); mu_assert_lf(lhmss_get(pmap, "z") == NULL);
	mu_assert_lf(lhmss_check_counts(pmap));

	lhmss_put(pmap, "y", "5");
	mu_assert_lf(pmap->num_occupied == 2);
	mu_assert_lf(!lhmss_has_key(pmap, "w")); mu_assert_lf(lhmss_get(pmap, "w") == NULL);
	mu_assert_lf( lhmss_has_key(pmap, "x")); mu_assert_lf(streq(lhmss_get(pmap, "x"), "3"));
	mu_assert_lf( lhmss_has_key(pmap, "y")); mu_assert_lf(streq(lhmss_get(pmap, "y"), "5"));
	mu_assert_lf(!lhmss_has_key(pmap, "z")); mu_assert_lf(lhmss_get(pmap, "z") == NULL);
	mu_assert_lf(lhmss_check_counts(pmap));

	lhmss_put(pmap, "x", "4");
	mu_assert_lf(pmap->num_occupied == 2);
	mu_assert_lf(!lhmss_has_key(pmap, "w")); mu_assert_lf(lhmss_get(pmap, "w") == NULL);
	mu_assert_lf( lhmss_has_key(pmap, "x")); mu_assert_lf(streq(lhmss_get(pmap, "x"), "4"));
	mu_assert_lf( lhmss_has_key(pmap, "y")); mu_assert_lf(streq(lhmss_get(pmap, "y"), "5"));
	mu_assert_lf(!lhmss_has_key(pmap, "z")); mu_assert_lf(lhmss_get(pmap, "z") == NULL);
	mu_assert_lf(lhmss_check_counts(pmap));

	lhmss_put(pmap, "z", "7");
	mu_assert_lf(pmap->num_occupied == 3);
	mu_assert_lf(!lhmss_has_key(pmap, "w")); mu_assert_lf(lhmss_get(pmap, "w") == NULL);
	mu_assert_lf( lhmss_has_key(pmap, "x")); mu_assert_lf(streq(lhmss_get(pmap, "x"), "4"));
	mu_assert_lf( lhmss_has_key(pmap, "y")); mu_assert_lf(streq(lhmss_get(pmap, "y"), "5"));
	mu_assert_lf( lhmss_has_key(pmap, "z")); mu_assert_lf(streq(lhmss_get(pmap, "z"), "7"));
	mu_assert_lf(lhmss_check_counts(pmap));

	lhmss_remove(pmap, "y");
	mu_assert_lf(pmap->num_occupied == 2);
	mu_assert_lf(!lhmss_has_key(pmap, "w")); mu_assert_lf(lhmss_get(pmap, "w") == NULL);
	mu_assert_lf( lhmss_has_key(pmap, "x")); mu_assert_lf(streq(lhmss_get(pmap, "x"), "4"));
	mu_assert_lf(!lhmss_has_key(pmap, "y")); mu_assert_lf(lhmss_get(pmap, "y") == NULL);
	mu_assert_lf( lhmss_has_key(pmap, "z")); mu_assert_lf(streq(lhmss_get(pmap, "z"), "7"));
	mu_assert_lf(lhmss_check_counts(pmap));

	lhmss_free(pmap);

	return NULL;
}