Home | History | Annotate | Line # | Download | only in tests
clear_parameters.c revision 1.1.1.1.4.2
      1  1.1.1.1.4.2  christos /* clear_parameters -- Deallocate memory for function parameters.
      2  1.1.1.1.4.2  christos 
      3  1.1.1.1.4.2  christos Copyright (C) 2012, 2013, 2014 INRIA
      4  1.1.1.1.4.2  christos 
      5  1.1.1.1.4.2  christos This file is part of GNU MPC.
      6  1.1.1.1.4.2  christos 
      7  1.1.1.1.4.2  christos GNU MPC is free software; you can redistribute it and/or modify it under
      8  1.1.1.1.4.2  christos the terms of the GNU Lesser General Public License as published by the
      9  1.1.1.1.4.2  christos Free Software Foundation; either version 3 of the License, or (at your
     10  1.1.1.1.4.2  christos option) any later version.
     11  1.1.1.1.4.2  christos 
     12  1.1.1.1.4.2  christos GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY
     13  1.1.1.1.4.2  christos WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
     14  1.1.1.1.4.2  christos FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
     15  1.1.1.1.4.2  christos more details.
     16  1.1.1.1.4.2  christos 
     17  1.1.1.1.4.2  christos You should have received a copy of the GNU Lesser General Public License
     18  1.1.1.1.4.2  christos along with this program. If not, see http://www.gnu.org/licenses/ .
     19  1.1.1.1.4.2  christos */
     20  1.1.1.1.4.2  christos 
     21  1.1.1.1.4.2  christos #include "mpc-tests.h"
     22  1.1.1.1.4.2  christos 
     23  1.1.1.1.4.2  christos static void
     24  1.1.1.1.4.2  christos clear_param (mpc_operand_t* p, mpc_param_t t)
     25  1.1.1.1.4.2  christos {
     26  1.1.1.1.4.2  christos   switch (t)
     27  1.1.1.1.4.2  christos     {
     28  1.1.1.1.4.2  christos     case NATIVE_INT:
     29  1.1.1.1.4.2  christos     case NATIVE_UL:
     30  1.1.1.1.4.2  christos     case NATIVE_L:
     31  1.1.1.1.4.2  christos     case NATIVE_D:
     32  1.1.1.1.4.2  christos       break;
     33  1.1.1.1.4.2  christos 
     34  1.1.1.1.4.2  christos     case GMP_Z:
     35  1.1.1.1.4.2  christos       mpz_clear (p->mpz);
     36  1.1.1.1.4.2  christos       break;
     37  1.1.1.1.4.2  christos     case GMP_Q:
     38  1.1.1.1.4.2  christos       mpq_clear (p->mpq);
     39  1.1.1.1.4.2  christos       break;
     40  1.1.1.1.4.2  christos     case GMP_F:
     41  1.1.1.1.4.2  christos       mpf_clear (p->mpf);
     42  1.1.1.1.4.2  christos       break;
     43  1.1.1.1.4.2  christos 
     44  1.1.1.1.4.2  christos     case MPFR_INEX:
     45  1.1.1.1.4.2  christos       break;
     46  1.1.1.1.4.2  christos     case MPFR:
     47  1.1.1.1.4.2  christos       mpfr_clear (p->mpfr);
     48  1.1.1.1.4.2  christos       break;
     49  1.1.1.1.4.2  christos 
     50  1.1.1.1.4.2  christos     case MPC_INEX:
     51  1.1.1.1.4.2  christos     case MPCC_INEX:
     52  1.1.1.1.4.2  christos       break;
     53  1.1.1.1.4.2  christos     case MPC:
     54  1.1.1.1.4.2  christos       mpc_clear (p->mpc);
     55  1.1.1.1.4.2  christos       break;
     56  1.1.1.1.4.2  christos 
     57  1.1.1.1.4.2  christos     case MPFR_RND:
     58  1.1.1.1.4.2  christos     case MPC_RND:
     59  1.1.1.1.4.2  christos       break;
     60  1.1.1.1.4.2  christos 
     61  1.1.1.1.4.2  christos     default:
     62  1.1.1.1.4.2  christos       fprintf (stderr, "clear_parameters: unsupported type.\n");
     63  1.1.1.1.4.2  christos       exit (1);
     64  1.1.1.1.4.2  christos     }
     65  1.1.1.1.4.2  christos }
     66  1.1.1.1.4.2  christos 
     67  1.1.1.1.4.2  christos void
     68  1.1.1.1.4.2  christos clear_parameters (mpc_fun_param_t *params)
     69  1.1.1.1.4.2  christos {
     70  1.1.1.1.4.2  christos   int in, out;
     71  1.1.1.1.4.2  christos   int total = params->nbout + params->nbin;
     72  1.1.1.1.4.2  christos 
     73  1.1.1.1.4.2  christos   free (params->name);
     74  1.1.1.1.4.2  christos   for (out = 0; out < params->nbout; out++)
     75  1.1.1.1.4.2  christos     {
     76  1.1.1.1.4.2  christos       clear_param (&(params->P[out]), params->T[out]);
     77  1.1.1.1.4.2  christos       clear_param (&(params->P[total + out]), params->T[out]);
     78  1.1.1.1.4.2  christos     }
     79  1.1.1.1.4.2  christos 
     80  1.1.1.1.4.2  christos   for (in = params->nbout; in < total; in++)
     81  1.1.1.1.4.2  christos     {
     82  1.1.1.1.4.2  christos       clear_param (&(params->P[in]), params->T[in]);
     83  1.1.1.1.4.2  christos     }
     84  1.1.1.1.4.2  christos }
     85