From ff3967f932f170a8b13c339bb812c65b0e6fd909 Mon Sep 17 00:00:00 2001 From: hasufell Date: Mon, 26 May 2014 21:38:39 +0200 Subject: [PATCH] STRING: provide function for deleting strings --- src/Makefile | 3 ++- src/ntru_string.c | 10 ++++++++++ src/ntru_string.h | 12 ++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index bed8d03..eefa212 100644 --- a/src/Makefile +++ b/src/Makefile @@ -37,7 +37,8 @@ endif LIBS += -L. -lgmp -lmpfr -lm # objects -PQC_OBJS = poly.o mem.o encrypt.o decrypt.o keypair.o ascii_poly.o file.o +PQC_OBJS = poly.o mem.o encrypt.o decrypt.o keypair.o ascii_poly.o file.o \ + ntru_string.o PQC_HEADERS = err.h poly.h context.h encrypt.h decrypt.h keypair.h \ ascii_poly.h common.h file.h ntru_string.h # CUNIT_OBJS = cunit.o diff --git a/src/ntru_string.c b/src/ntru_string.c index ff91c05..6e1ae20 100644 --- a/src/ntru_string.c +++ b/src/ntru_string.c @@ -25,3 +25,13 @@ * like C strings and provides operations on it. * @brief string type and operations */ + +#include "ntru_string.h" + + +void +string_delete(string *del_string) +{ + free(del_string->ptr); + free(del_string); +} diff --git a/src/ntru_string.h b/src/ntru_string.h index d052b39..294eec7 100644 --- a/src/ntru_string.h +++ b/src/ntru_string.h @@ -51,4 +51,16 @@ struct string { }; +/** + * Delete the inner structure + * of the string and frees the string + * itself from the heap. Must not be + * called on stack variables. + * + * @param del_string the string to delete + */ +void +string_delete(string *del_string); + + #endif /* NTRU_STRING_H */