static void sc_card_free(sc_card_t *card) { sc_free_apps(card); sc_free_ef_atr(card); if (card->ef_dir != NULL) sc_file_free(card->ef_dir); free(card->ops); if (card->algorithms != NULL) free(card->algorithms); if (card->mutex != NULL) { int r = sc_mutex_destroy(card->ctx, card->mutex); if (r != SC_SUCCESS) sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unable to destroy mutex"); } sc_mem_clear(card, sizeof(*card)); free(card); }
static void sc_card_free(sc_card_t *card) { sc_free_apps(card); sc_free_ef_atr(card); if (card->ef_dir != NULL) sc_file_free(card->ef_dir); free(card->ops); if (card->algorithms != NULL) { int i; for (i=0; i<card->algorithm_count; i++) { struct sc_algorithm_info *info = (card->algorithms + i); if (info->algorithm == SC_ALGORITHM_EC) { struct sc_ec_parameters ep = info->u._ec.params; free(ep.named_curve); free(ep.der.value); } } free(card->algorithms); card->algorithms = NULL; card->algorithm_count = 0; } if (card->cache.current_ef) sc_file_free(card->cache.current_ef); if (card->cache.current_df) sc_file_free(card->cache.current_df); if (card->mutex != NULL) { int r = sc_mutex_destroy(card->ctx, card->mutex); if (r != SC_SUCCESS) sc_log(card->ctx, "unable to destroy mutex"); } sc_mem_clear(card, sizeof(*card)); free(card); }