LCOV - code coverage report
Current view: top level - exchangedb - plugin_exchangedb_common.c (source / functions) Hit Total Coverage
Test: GNU Taler coverage report Lines: 51 63 81.0 %
Date: 2021-04-12 06:08:44 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   Copyright (C) 2015, 2016, 2020 Taler Systems SA
       4             : 
       5             :   TALER is free software; you can redistribute it and/or modify it under the
       6             :   terms of the GNU General Public License as published by the Free Software
       7             :   Foundation; either version 3, or (at your option) any later version.
       8             : 
       9             :   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
      10             :   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
      11             :   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
      12             : 
      13             :   You should have received a copy of the GNU General Public License along with
      14             :   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
      15             : */
      16             : /**
      17             :  * @file exchangedb/plugin_exchangedb_common.c
      18             :  * @brief Functions shared across plugins, this file is meant to be
      19             :  *        included in each plugin.
      20             :  * @author Christian Grothoff
      21             :  */
      22             : 
      23             : /**
      24             :  * Free memory associated with the given reserve history.
      25             :  *
      26             :  * @param cls the @e cls of this struct with the plugin-specific state (unused)
      27             :  * @param rh history to free.
      28             :  */
      29             : static void
      30           1 : common_free_reserve_history (void *cls,
      31             :                              struct TALER_EXCHANGEDB_ReserveHistory *rh)
      32             : {
      33             :   (void) cls;
      34           6 :   while (NULL != rh)
      35             :   {
      36           5 :     switch (rh->type)
      37             :     {
      38           2 :     case TALER_EXCHANGEDB_RO_BANK_TO_EXCHANGE:
      39             :       {
      40             :         struct TALER_EXCHANGEDB_BankTransfer *bt;
      41             : 
      42           2 :         bt = rh->details.bank;
      43           2 :         GNUNET_free (bt->sender_account_details);
      44           2 :         GNUNET_free (bt);
      45           2 :         break;
      46             :       }
      47           1 :     case TALER_EXCHANGEDB_RO_WITHDRAW_COIN:
      48             :       {
      49             :         struct TALER_EXCHANGEDB_CollectableBlindcoin *cbc;
      50             : 
      51           1 :         cbc = rh->details.withdraw;
      52           1 :         GNUNET_CRYPTO_rsa_signature_free (cbc->sig.rsa_signature);
      53           1 :         GNUNET_free (cbc);
      54           1 :         break;
      55             :       }
      56           1 :     case TALER_EXCHANGEDB_RO_RECOUP_COIN:
      57             :       {
      58             :         struct TALER_EXCHANGEDB_Recoup *recoup;
      59             : 
      60           1 :         recoup = rh->details.recoup;
      61           1 :         GNUNET_CRYPTO_rsa_signature_free (recoup->coin.denom_sig.rsa_signature);
      62           1 :         GNUNET_free (recoup);
      63           1 :         break;
      64             :       }
      65           1 :     case TALER_EXCHANGEDB_RO_EXCHANGE_TO_BANK:
      66             :       {
      67             :         struct TALER_EXCHANGEDB_ClosingTransfer *closing;
      68             : 
      69           1 :         closing = rh->details.closing;
      70           1 :         GNUNET_free (closing->receiver_account_details);
      71           1 :         GNUNET_free (closing);
      72           1 :         break;
      73             :       }
      74             :     }
      75           5 :     {
      76             :       struct TALER_EXCHANGEDB_ReserveHistory *next;
      77             : 
      78           5 :       next = rh->next;
      79           5 :       GNUNET_free (rh);
      80           5 :       rh = next;
      81             :     }
      82             :   }
      83           1 : }
      84             : 
      85             : 
      86             : /**
      87             :  * Free linked list of transactions.
      88             :  *
      89             :  * @param cls the @e cls of this struct with the plugin-specific state (unused)
      90             :  * @param tl list to free
      91             :  */
      92             : static void
      93           2 : common_free_coin_transaction_list (void *cls,
      94             :                                    struct TALER_EXCHANGEDB_TransactionList *tl)
      95             : {
      96             :   (void) cls;
      97           6 :   while (NULL != tl)
      98             :   {
      99           4 :     switch (tl->type)
     100             :     {
     101           1 :     case TALER_EXCHANGEDB_TT_DEPOSIT:
     102             :       {
     103             :         struct TALER_EXCHANGEDB_DepositListEntry *deposit;
     104             : 
     105           1 :         deposit = tl->details.deposit;
     106           1 :         if (NULL != deposit->receiver_wire_account)
     107           1 :           json_decref (deposit->receiver_wire_account);
     108           1 :         GNUNET_free (deposit);
     109           1 :         break;
     110             :       }
     111           1 :     case TALER_EXCHANGEDB_TT_MELT:
     112           1 :       GNUNET_free (tl->details.melt);
     113           1 :       break;
     114           0 :     case TALER_EXCHANGEDB_TT_OLD_COIN_RECOUP:
     115             :       {
     116             :         struct TALER_EXCHANGEDB_RecoupRefreshListEntry *rr;
     117             : 
     118           0 :         rr = tl->details.old_coin_recoup;
     119           0 :         if (NULL != rr->coin.denom_sig.rsa_signature)
     120           0 :           GNUNET_CRYPTO_rsa_signature_free (rr->coin.denom_sig.rsa_signature);
     121           0 :         GNUNET_free (rr);
     122           0 :         break;
     123             :       }
     124           1 :     case TALER_EXCHANGEDB_TT_REFUND:
     125           1 :       GNUNET_free (tl->details.refund);
     126           1 :       break;
     127           1 :     case TALER_EXCHANGEDB_TT_RECOUP:
     128           1 :       GNUNET_free (tl->details.recoup);
     129           1 :       break;
     130           0 :     case TALER_EXCHANGEDB_TT_RECOUP_REFRESH:
     131             :       {
     132             :         struct TALER_EXCHANGEDB_RecoupRefreshListEntry *rr;
     133             : 
     134           0 :         rr = tl->details.recoup_refresh;
     135           0 :         if (NULL != rr->coin.denom_sig.rsa_signature)
     136           0 :           GNUNET_CRYPTO_rsa_signature_free (rr->coin.denom_sig.rsa_signature);
     137           0 :         GNUNET_free (rr);
     138           0 :         break;
     139             :       }
     140             :     }
     141           4 :     {
     142             :       struct TALER_EXCHANGEDB_TransactionList *next;
     143             : 
     144           4 :       next = tl->next;
     145           4 :       GNUNET_free (tl);
     146           4 :       tl = next;
     147             :     }
     148             :   }
     149           2 : }
     150             : 
     151             : 
     152             : /* end of plugin_exchangedb_common.c */

Generated by: LCOV version 1.14