LCOV - code coverage report
Current view: top level - exchangedb - plugin_exchangedb_common.c (source / functions) Hit Total Coverage
Test: rcoverage.info Lines: 70 70 100.0 %
Date: 2017-11-25 11:31:41 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   Copyright (C) 2015, 2016 Inria & GNUnet e.V.
       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          10 : common_free_reserve_history (void *cls,
      31             :                              struct TALER_EXCHANGEDB_ReserveHistory *rh)
      32             : {
      33             :   struct TALER_EXCHANGEDB_BankTransfer *bt;
      34             :   struct TALER_EXCHANGEDB_CollectableBlindcoin *cbc;
      35             :   struct TALER_EXCHANGEDB_Payback *payback;
      36             :   struct TALER_EXCHANGEDB_ReserveHistory *backref;
      37             :   struct TALER_EXCHANGEDB_ClosingTransfer *closing;
      38             : 
      39          39 :   while (NULL != rh)
      40             :   {
      41          19 :     switch(rh->type)
      42             :     {
      43             :     case TALER_EXCHANGEDB_RO_BANK_TO_EXCHANGE:
      44          11 :       bt = rh->details.bank;
      45          11 :       if (NULL != bt->sender_account_details)
      46          11 :         json_decref (bt->sender_account_details);
      47          11 :       GNUNET_free_non_null (bt->wire_reference);
      48          11 :       GNUNET_free (bt);
      49          11 :       break;
      50             :     case TALER_EXCHANGEDB_RO_WITHDRAW_COIN:
      51           5 :       cbc = rh->details.withdraw;
      52           5 :       GNUNET_CRYPTO_rsa_signature_free (cbc->sig.rsa_signature);
      53           5 :       GNUNET_CRYPTO_rsa_public_key_free (cbc->denom_pub.rsa_public_key);
      54           5 :       GNUNET_free (cbc);
      55           5 :       break;
      56             :     case TALER_EXCHANGEDB_RO_PAYBACK_COIN:
      57           2 :       payback = rh->details.payback;
      58           2 :       GNUNET_CRYPTO_rsa_signature_free (payback->coin.denom_sig.rsa_signature);
      59           2 :       GNUNET_CRYPTO_rsa_public_key_free (payback->coin.denom_pub.rsa_public_key);
      60           2 :       GNUNET_free (payback);
      61           2 :       break;
      62             :     case TALER_EXCHANGEDB_RO_EXCHANGE_TO_BANK:
      63           1 :       closing = rh->details.closing;
      64           1 :       if (NULL != closing->receiver_account_details)
      65           1 :         json_decref (closing->receiver_account_details);
      66           1 :       GNUNET_free (closing);
      67           1 :       break;
      68             :     }
      69          19 :     backref = rh;
      70          19 :     rh = rh->next;
      71          19 :     GNUNET_free (backref);
      72             :   }
      73          10 : }
      74             : 
      75             : 
      76             : /**
      77             :  * Free memory of the link data list.
      78             :  *
      79             :  * @param cls the @e cls of this struct with the plugin-specific state (unused)
      80             :  * @param ldl link data list to release
      81             :  */
      82             : static void
      83           2 : common_free_link_data_list (void *cls,
      84             :                             struct TALER_EXCHANGEDB_LinkDataList *ldl)
      85             : {
      86             :   struct TALER_EXCHANGEDB_LinkDataList *next;
      87             : 
      88          26 :   while (NULL != ldl)
      89             :   {
      90          22 :     next = ldl->next;
      91          22 :     if (NULL != ldl->denom_pub.rsa_public_key)
      92          22 :         GNUNET_CRYPTO_rsa_public_key_free (ldl->denom_pub.rsa_public_key);
      93          22 :       if (NULL != ldl->ev_sig.rsa_signature)
      94          22 :         GNUNET_CRYPTO_rsa_signature_free (ldl->ev_sig.rsa_signature);
      95          22 :     GNUNET_free (ldl);
      96          22 :     ldl = next;
      97             :   }
      98           2 : }
      99             : 
     100             : 
     101             : /**
     102             :  * Free linked list of transactions.
     103             :  *
     104             :  * @param cls the @e cls of this struct with the plugin-specific state (unused)
     105             :  * @param list list to free
     106             :  */
     107             : static void
     108          19 : common_free_coin_transaction_list (void *cls,
     109             :                                    struct TALER_EXCHANGEDB_TransactionList *list)
     110             : {
     111             :   struct TALER_EXCHANGEDB_TransactionList *next;
     112             : 
     113          57 :   while (NULL != list)
     114             :   {
     115          19 :     next = list->next;
     116             : 
     117          19 :     switch (list->type)
     118             :     {
     119             :     case TALER_EXCHANGEDB_TT_DEPOSIT:
     120          12 :       json_decref (list->details.deposit->receiver_wire_account);
     121          12 :       if (NULL != list->details.deposit->coin.denom_pub.rsa_public_key)
     122          12 :         GNUNET_CRYPTO_rsa_public_key_free (list->details.deposit->coin.denom_pub.rsa_public_key);
     123          12 :       if (NULL != list->details.deposit->coin.denom_sig.rsa_signature)
     124          12 :         GNUNET_CRYPTO_rsa_signature_free (list->details.deposit->coin.denom_sig.rsa_signature);
     125          12 :       GNUNET_free (list->details.deposit);
     126          12 :       break;
     127             :     case TALER_EXCHANGEDB_TT_REFRESH_MELT:
     128           2 :       if (NULL != list->details.melt->coin.denom_pub.rsa_public_key)
     129           2 :         GNUNET_CRYPTO_rsa_public_key_free (list->details.melt->coin.denom_pub.rsa_public_key);
     130           2 :       if (NULL != list->details.melt->coin.denom_sig.rsa_signature)
     131           2 :         GNUNET_CRYPTO_rsa_signature_free (list->details.melt->coin.denom_sig.rsa_signature);
     132           2 :       GNUNET_free (list->details.melt);
     133           2 :       break;
     134             :     case TALER_EXCHANGEDB_TT_REFUND:
     135           3 :       if (NULL != list->details.refund->coin.denom_pub.rsa_public_key)
     136           3 :         GNUNET_CRYPTO_rsa_public_key_free (list->details.refund->coin.denom_pub.rsa_public_key);
     137           3 :       if (NULL != list->details.refund->coin.denom_sig.rsa_signature)
     138           3 :         GNUNET_CRYPTO_rsa_signature_free (list->details.refund->coin.denom_sig.rsa_signature);
     139           3 :       GNUNET_free (list->details.refund);
     140           3 :       break;
     141             :     case TALER_EXCHANGEDB_TT_PAYBACK:
     142           2 :       if (NULL != list->details.payback->coin.denom_pub.rsa_public_key)
     143           2 :         GNUNET_CRYPTO_rsa_public_key_free (list->details.payback->coin.denom_pub.rsa_public_key);
     144           2 :       if (NULL != list->details.payback->coin.denom_sig.rsa_signature)
     145           2 :         GNUNET_CRYPTO_rsa_signature_free (list->details.payback->coin.denom_sig.rsa_signature);
     146           2 :       GNUNET_free (list->details.payback);
     147           2 :       break;
     148             :     }
     149          19 :     GNUNET_free (list);
     150          19 :     list = next;
     151             :   }
     152          19 : }
     153             : 
     154             : 
     155             : /* end of plugin_exchangedb_common.c */

Generated by: LCOV version 1.13