diff --git a/src/poly.c b/src/poly.c index d96a09d..b6dfe14 100644 --- a/src/poly.c +++ b/src/poly.c @@ -74,6 +74,20 @@ void init_polynom_size(pb_poly *new_poly, mp_int *chara, int size) } } +/** + * This deletes the internal structure of a polynomial, + * and frees the pointer. Don't call this on stack variables, + * this is intended for use after ntru_ functions, that + * return a polynomial pointer. + * + * @param poly the polynomial to delete + */ +void delete_polynom(pb_poly *poly) +{ + pb_clear(poly); + free(poly); +} + /** * Print the polynomial in a human readable format to stdout. * diff --git a/src/poly.h b/src/poly.h index 27e39a2..6bca69d 100644 --- a/src/poly.h +++ b/src/poly.h @@ -33,6 +33,8 @@ void init_polynom(pb_poly *new_poly, mp_int *chara); void init_polynom_size(pb_poly *new_poly, mp_int *chara, int size); +void delete_polynom(pb_poly *new_poly); + void draw_polynom(pb_poly * const poly); #endif /* NTRU_POLY_H */