CH_IR_RET_E ch_ir_indexer_deinit(
   CH_IR_INDEXER_CTXT_X *px_indexer_ctxt)
{
   CH_IR_RET_E e_ret_val = eCH_IR_RET_FAILURE;
   HM_FOR_EACH_PARAMS_X x_for_each_param = {eHM_DATA_STRUCT_INVALID};
   HM_RET_E e_hm_ret = eHM_RET_FAILURE;

   if (NULL == px_indexer_ctxt)
   {
      CH_IR_LOG_MED("Invalid Args");
      e_ret_val = eCH_IR_RET_INVALID_ARGS;
      goto CLEAN_RETURN;
   }

   (void) ch_ir_indexer_delete_index (px_indexer_ctxt);
   /*
    * TODO: Cleanup stopwords hashmap.
    */

   if (NULL != px_indexer_ctxt->hl_stopword_hm)
   {
      x_for_each_param.e_data_structure = eHM_DATA_STRUCT_LINKED_LIST;
      x_for_each_param.e_direction = eHM_FOR_EACH_DIRECTION_FORWARD;
      e_hm_ret = hm_for_each_v2 (px_indexer_ctxt->hl_token_hm,
         &x_for_each_param, ch_ir_indexer_stopwords_hm_for_each_delete_cbk,
         px_indexer_ctxt);

      (void) hm_delete_all_nodes (px_indexer_ctxt->hl_stopword_hm);

      (void) hm_delete (px_indexer_ctxt->hl_stopword_hm);
      px_indexer_ctxt->hl_stopword_hm = NULL;
   }

   if (NULL != px_indexer_ctxt->px_dir_parser_ctxt)
   {
      (void) ch_ir_dir_parser_deinit(px_indexer_ctxt->px_dir_parser_ctxt);
      px_indexer_ctxt->px_dir_parser_ctxt = NULL;
   }

   if (NULL != px_indexer_ctxt->px_tokenizer_ctxt)
   {
      (void) ch_ir_tokenizer_deinit(px_indexer_ctxt->px_tokenizer_ctxt);
      px_indexer_ctxt->px_tokenizer_ctxt = NULL;
   }

   if (NULL != px_indexer_ctxt->hl_token_hm)
   {
      (void) hm_delete (px_indexer_ctxt->hl_token_hm);
      px_indexer_ctxt->hl_token_hm = NULL;
   }

   pal_free (px_indexer_ctxt);
   px_indexer_ctxt = NULL;
   e_ret_val = eCH_IR_RET_SUCCESS;

CLEAN_RETURN:
   return e_ret_val;
}
Exemple #2
0
void cleanup() {
    hm_delete(settings, NULL);
    hm_delete(batt_info, NULL);
}
Exemple #3
0
int hm_destroy(hashMap *hashmap){
    hm_delete(hashmap);
    return 1;
}