summaryrefslogtreecommitdiff
path: root/tests/clear_parameters.c
blob: d5c74f87f0a1cdccc2fca432e3f94edfe3c1c9fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* clear_parameters -- Deallocate memory for function parameters.

Copyright (C) 2012, 2013 INRIA

This file is part of GNU MPC.

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

GNU MPC 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 Lesser General Public License for
more details.

You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see http://www.gnu.org/licenses/ .
*/

#include "mpc-tests.h"

static void
clear_param (mpc_operand_t* p, mpc_param_t t)
{
  switch (t)
    {
    case NATIVE_INT:
    case NATIVE_UL:
    case NATIVE_L:
    case NATIVE_D:
      break;

    case GMP_Z:
      mpz_clear (p->mpz);
      break;
    case GMP_Q:
      mpq_clear (p->mpq);
      break;
    case GMP_F:
      mpf_clear (p->mpf);
      break;

    case MPFR_INEX:
      break;
    case MPFR:
      mpfr_clear (p->mpfr);
      break;

    case MPC_INEX:
      break;
    case MPC:
      mpc_clear (p->mpc);
      break;

    case MPFR_RND:
    case MPC_RND:
      break;

    default:
      fprintf (stderr, "clear_parameters: unsupported type.\n");
      exit (1);
    }
}

void
clear_parameters (mpc_fun_param_t *params)
{
  int in, out;
  int total = params->nbout + params->nbin;

  for (out = 0; out < params->nbout; out++)
    {
      clear_param (&(params->P[out]), params->T[out]);
      clear_param (&(params->P[total + out]), params->T[out]);
    }

  for (in = params->nbout; in < total; in++)
    {
      clear_param (&(params->P[in]), params->T[in]);
    }
}