static acc_t* acc_mode_alloc() { acc_t* pacc = mlr_malloc_or_die(sizeof(acc_t)); acc_mode_state_t* pstate = mlr_malloc_or_die(sizeof(acc_mode_state_t)); pstate->pcounts_for_value = lhmsi_alloc(); pacc->pvstate = (void*)pstate; pacc->psingest_func = &acc_mode_singest; pacc->pdingest_func = NULL; pacc->pemit_func = &acc_mode_emit; return pacc; }
static lhmsi_t* get_default_repeat_ipses() { if (singleton_default_repeat_ipses == NULL) { singleton_default_repeat_ipses = lhmsi_alloc(); lhmsi_put(singleton_default_repeat_ipses, "dkvp", FALSE); lhmsi_put(singleton_default_repeat_ipses, "csv", FALSE); lhmsi_put(singleton_default_repeat_ipses, "csvlite", FALSE); lhmsi_put(singleton_default_repeat_ipses, "nidx", FALSE); lhmsi_put(singleton_default_repeat_ipses, "xtab", TRUE); lhmsi_put(singleton_default_repeat_ipses, "pprint", FALSE); } return singleton_default_repeat_ipses; }
stats1_acc_t* stats1_mode_alloc(char* value_field_name, char* stats1_acc_name, int allow_int_float) { stats1_acc_t* pstats1_acc = mlr_malloc_or_die(sizeof(stats1_acc_t)); stats1_mode_state_t* pstate = mlr_malloc_or_die(sizeof(stats1_mode_state_t)); pstate->pcounts_for_value = lhmsi_alloc(); pstate->output_field_name = mlr_paste_3_strings(value_field_name, "_", stats1_acc_name); pstats1_acc->pvstate = (void*)pstate; pstats1_acc->pdingest_func = NULL; pstats1_acc->pningest_func = NULL; pstats1_acc->psingest_func = stats1_mode_singest; pstats1_acc->pemit_func = stats1_mode_emit; pstats1_acc->pfree_func = stats1_mode_free; return pstats1_acc; }
// ---------------------------------------------------------------- static char* test_lhmsi() { mu_assert_lf(0 == 0); lhmsi_t *pmap = lhmsi_alloc(); mu_assert_lf(pmap->num_occupied == 0); mu_assert_lf(!lhmsi_has_key(pmap, "w")); mu_assert_lf(!lhmsi_has_key(pmap, "x")); mu_assert_lf(!lhmsi_has_key(pmap, "y")); mu_assert_lf(!lhmsi_has_key(pmap, "z")); mu_assert_lf(lhmsi_check_counts(pmap)); lhmsi_put(pmap, "x", 3); mu_assert_lf(pmap->num_occupied == 1); mu_assert_lf(!lhmsi_has_key(pmap, "w")); mu_assert_lf(lhmsi_has_key(pmap, "x")); mu_assert_lf(!lhmsi_has_key(pmap, "y")); mu_assert_lf(!lhmsi_has_key(pmap, "z")); mu_assert_lf(lhmsi_check_counts(pmap)); lhmsi_put(pmap, "y", 5); mu_assert_lf(pmap->num_occupied == 2); mu_assert_lf(!lhmsi_has_key(pmap, "w")); mu_assert_lf(lhmsi_has_key(pmap, "x")); mu_assert_lf(lhmsi_has_key(pmap, "y")); mu_assert_lf(!lhmsi_has_key(pmap, "z")); mu_assert_lf(lhmsi_check_counts(pmap)); lhmsi_put(pmap, "x", 4); mu_assert_lf(pmap->num_occupied == 2); mu_assert_lf(!lhmsi_has_key(pmap, "w")); mu_assert_lf(lhmsi_has_key(pmap, "x")); mu_assert_lf(lhmsi_has_key(pmap, "y")); mu_assert_lf(!lhmsi_has_key(pmap, "z")); mu_assert_lf(lhmsi_check_counts(pmap)); lhmsi_put(pmap, "z", 7); mu_assert_lf(pmap->num_occupied == 3); mu_assert_lf(!lhmsi_has_key(pmap, "w")); mu_assert_lf(lhmsi_has_key(pmap, "x")); mu_assert_lf(lhmsi_has_key(pmap, "y")); mu_assert_lf(lhmsi_has_key(pmap, "z")); mu_assert_lf(lhmsi_check_counts(pmap)); lhmsi_remove(pmap, "y"); mu_assert_lf(pmap->num_occupied == 2); mu_assert_lf(!lhmsi_has_key(pmap, "w")); mu_assert_lf(lhmsi_has_key(pmap, "x")); mu_assert_lf(!lhmsi_has_key(pmap, "y")); mu_assert_lf(lhmsi_has_key(pmap, "z")); mu_assert_lf(lhmsi_check_counts(pmap)); lhmsi_clear(pmap); mu_assert_lf(pmap->num_occupied == 0); mu_assert_lf(!lhmsi_has_key(pmap, "w")); mu_assert_lf(!lhmsi_has_key(pmap, "x")); mu_assert_lf(!lhmsi_has_key(pmap, "y")); mu_assert_lf(!lhmsi_has_key(pmap, "z")); mu_assert_lf(lhmsi_check_counts(pmap)); lhmsi_free(pmap); return NULL; }