/*
  This file is part of TALER
  Copyright (C) 2015, 2016, 2020, 2024 Taler Systems SA

  TALER is free software; you can redistribute it and/or modify it under the
  terms of the GNU General Public License as published by the Free Software
  Foundation; either version 3, or (at your option) any later version.

  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

  You should have received a copy of the GNU General Public License along with
  TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
*/
/**
 * @file exchangedb/free_coin_transaction_list.c
 * @brief Implementation to free the coin transaction list
 * @author Christian Grothoff
 */
#include "platform.h"
#include "exchange-database/free_coin_transaction_list.h"


void
TALER_EXCHANGEDB_free_coin_transaction_list (
  struct TALER_EXCHANGEDB_TransactionList *tl)
{
  while (NULL != tl)
  {
    switch (tl->type)
    {
    case TALER_EXCHANGEDB_TT_DEPOSIT:
      {
        struct TALER_EXCHANGEDB_DepositListEntry *deposit;

        deposit = tl->details.deposit;
        GNUNET_free (deposit->receiver_wire_account.full_payto);
        GNUNET_free (deposit);
        break;
      }
    case TALER_EXCHANGEDB_TT_MELT:
      GNUNET_free (tl->details.melt);
      break;
    case TALER_EXCHANGEDB_TT_RECOUP_REFRESH_RECEIVER:
      {
        struct TALER_EXCHANGEDB_RecoupRefreshListEntry *rr;

        rr = tl->details.old_coin_recoup;
        TALER_denom_sig_free (&rr->coin.denom_sig);
        GNUNET_free (rr);
        break;
      }
    case TALER_EXCHANGEDB_TT_REFUND:
      GNUNET_free (tl->details.refund);
      break;
    case TALER_EXCHANGEDB_TT_RECOUP_WITHDRAW:
      GNUNET_free (tl->details.recoup);
      break;
    case TALER_EXCHANGEDB_TT_RECOUP_REFRESH:
      {
        struct TALER_EXCHANGEDB_RecoupRefreshListEntry *rr;

        rr = tl->details.recoup_refresh;
        TALER_denom_sig_free (&rr->coin.denom_sig);
        GNUNET_free (rr);
        break;
      }
    case TALER_EXCHANGEDB_TT_PURSE_DEPOSIT:
      {
        struct TALER_EXCHANGEDB_PurseDepositListEntry *deposit;

        deposit = tl->details.purse_deposit;
        GNUNET_free (deposit->exchange_base_url);
        GNUNET_free (deposit);
        break;
      }
    case TALER_EXCHANGEDB_TT_PURSE_REFUND:
      {
        struct TALER_EXCHANGEDB_PurseRefundListEntry *prefund;

        prefund = tl->details.purse_refund;
        GNUNET_free (prefund);
        break;
      }
    case TALER_EXCHANGEDB_TT_RESERVE_OPEN:
      {
        struct TALER_EXCHANGEDB_ReserveOpenListEntry *role;

        role = tl->details.reserve_open;
        GNUNET_free (role);
        break;
      }
    }
    {
      struct TALER_EXCHANGEDB_TransactionList *next;

      next = tl->next;
      GNUNET_free (tl);
      tl = next;
    }
  }
}


/* end of free_coin_transaction_list.c */
