Merge pull request #4 from thesamesam/develop
[libtompoly.git] / pb_clear.c
blob854c89631ab372d518ab51bae2a13c5a1f3903bf
1 /* LibTomPoly, Polynomial Basis Math -- Tom St Denis
2 *
3 * LibTomPoly is a public domain library that provides
4 * polynomial basis arithmetic support. It relies on
5 * LibTomMath for large integer support.
7 * This library is free for all purposes without any
8 * express guarantee that it works.
10 * Tom St Denis, tomstdenis@iahu.ca, http://poly.libtomcrypt.org
12 #include <tompoly.h>
13 #include <stdlib.h>
15 void pb_clear(pb_poly *a)
17 int x;
19 if (a->terms != NULL) {
20 /* free stuff */
21 for (x = 0; x < a->alloc; x++) {
22 mp_clear(&(a->terms[x]));
24 free(a->terms);
25 mp_clear(&(a->characteristic));
27 /* prevent double frees */
28 a->terms = NULL;
29 a->alloc = a->used = 0;