LCOV - code coverage report
Current view: top level - exchangedb - plugin_exchangedb_common.c (source / functions) Hit Total Coverage
Test: GNU Taler exchange coverage report Lines: 63 63 100.0 %
Date: 2021-08-30 06:43:37 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          12 : common_free_reserve_history (void *cls,
      31             :                              struct TALER_EXCHANGEDB_ReserveHistory *rh)
      32             : {
      33             :   (void) cls;
      34          51 :   while (NULL != rh)
      35             :   {
      36          39 :     switch (rh->type)
      37             :     {
      38          13 :     case TALER_EXCHANGEDB_RO_BANK_TO_EXCHANGE:
      39             :       {
      40             :         struct TALER_EXCHANGEDB_BankTransfer *bt;
      41             : 
      42          13 :         bt = rh->details.bank;
      43          13 :         GNUNET_free (bt->sender_account_details);
      44          13 :         GNUNET_free (bt);
      45          13 :         break;
      46             :       }
      47          15 :     case TALER_EXCHANGEDB_RO_WITHDRAW_COIN:
      48             :       {
      49             :         struct TALER_EXCHANGEDB_CollectableBlindcoin *cbc;
      50             : 
      51          15 :         cbc = rh->details.withdraw;
      52          15 :         GNUNET_CRYPTO_rsa_signature_free (cbc->sig.rsa_signature);
      53          15 :         GNUNET_free (cbc);
      54          15 :         break;
      55             :       }
      56           5 :     case TALER_EXCHANGEDB_RO_RECOUP_COIN:
      57             :       {
      58             :         struct TALER_EXCHANGEDB_Recoup *recoup;
      59             : 
      60           5 :         recoup = rh->details.recoup;
      61           5 :         GNUNET_CRYPTO_rsa_signature_free (recoup->coin.denom_sig.rsa_signature);
      62           5 :         GNUNET_free (recoup);
      63           5 :         break;
      64             :       }
      65           6 :     case TALER_EXCHANGEDB_RO_EXCHANGE_TO_BANK:
      66             :       {
      67             :         struct TALER_EXCHANGEDB_ClosingTransfer *closing;
      68             : 
      69           6 :         closing = rh->details.closing;
      70           6 :         GNUNET_free (closing->receiver_account_details);
      71           6 :         GNUNET_free (closing);
      72           6 :         break;
      73             :       }
      74             :     }
      75          39 :     {
      76             :       struct TALER_EXCHANGEDB_ReserveHistory *next;
      77             : 
      78          39 :       next = rh->next;
      79          39 :       GNUNET_free (rh);
      80          39 :       rh = next;
      81             :     }
      82             :   }
      83          12 : }
      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         154 : common_free_coin_transaction_list (void *cls,
      94             :                                    struct TALER_EXCHANGEDB_TransactionList *tl)
      95             : {
      96             :   (void) cls;
      97         415 :   while (NULL != tl)
      98             :   {
      99         261 :     switch (tl->type)
     100             :     {
     101          94 :     case TALER_EXCHANGEDB_TT_DEPOSIT:
     102             :       {
     103             :         struct TALER_EXCHANGEDB_DepositListEntry *deposit;
     104             : 
     105          94 :         deposit = tl->details.deposit;
     106          94 :         if (NULL != deposit->receiver_wire_account)
     107          94 :           json_decref (deposit->receiver_wire_account);
     108          94 :         GNUNET_free (deposit);
     109          94 :         break;
     110             :       }
     111         121 :     case TALER_EXCHANGEDB_TT_MELT:
     112         121 :       GNUNET_free (tl->details.melt);
     113         121 :       break;
     114          17 :     case TALER_EXCHANGEDB_TT_OLD_COIN_RECOUP:
     115             :       {
     116             :         struct TALER_EXCHANGEDB_RecoupRefreshListEntry *rr;
     117             : 
     118          17 :         rr = tl->details.old_coin_recoup;
     119          17 :         if (NULL != rr->coin.denom_sig.rsa_signature)
     120          17 :           GNUNET_CRYPTO_rsa_signature_free (rr->coin.denom_sig.rsa_signature);
     121          17 :         GNUNET_free (rr);
     122          17 :         break;
     123             :       }
     124          23 :     case TALER_EXCHANGEDB_TT_REFUND:
     125          23 :       GNUNET_free (tl->details.refund);
     126          23 :       break;
     127           2 :     case TALER_EXCHANGEDB_TT_RECOUP:
     128           2 :       GNUNET_free (tl->details.recoup);
     129           2 :       break;
     130           4 :     case TALER_EXCHANGEDB_TT_RECOUP_REFRESH:
     131             :       {
     132             :         struct TALER_EXCHANGEDB_RecoupRefreshListEntry *rr;
     133             : 
     134           4 :         rr = tl->details.recoup_refresh;
     135           4 :         if (NULL != rr->coin.denom_sig.rsa_signature)
     136           4 :           GNUNET_CRYPTO_rsa_signature_free (rr->coin.denom_sig.rsa_signature);
     137           4 :         GNUNET_free (rr);
     138           4 :         break;
     139             :       }
     140             :     }
     141         261 :     {
     142             :       struct TALER_EXCHANGEDB_TransactionList *next;
     143             : 
     144         261 :       next = tl->next;
     145         261 :       GNUNET_free (tl);
     146         261 :       tl = next;
     147             :     }
     148             :   }
     149         154 : }
     150             : 
     151             : 
     152             : /* end of plugin_exchangedb_common.c */

Generated by: LCOV version 1.14