summaryrefslogtreecommitdiff
path: root/src/libstrongswan/bio
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@debian.org>2013-04-26 14:57:47 +0200
committerYves-Alexis Perez <corsac@debian.org>2013-04-26 14:57:47 +0200
commit10e5fb2b9b2f27c83b3e5a1d048b158d5cf42a43 (patch)
treebf1d05a2e37dbd1911b86fcc026fbe49b0239c71 /src/libstrongswan/bio
parent7585facf05d927eb6df3929ce09ed5e60d905437 (diff)
downloadvyos-strongswan-10e5fb2b9b2f27c83b3e5a1d048b158d5cf42a43.tar.gz
vyos-strongswan-10e5fb2b9b2f27c83b3e5a1d048b158d5cf42a43.zip
Imported Upstream version 5.0.3
Diffstat (limited to 'src/libstrongswan/bio')
-rw-r--r--src/libstrongswan/bio/bio_reader.c20
-rw-r--r--src/libstrongswan/bio/bio_reader.h13
2 files changed, 32 insertions, 1 deletions
diff --git a/src/libstrongswan/bio/bio_reader.c b/src/libstrongswan/bio/bio_reader.c
index 17815d6c0..29b9e7279 100644
--- a/src/libstrongswan/bio/bio_reader.c
+++ b/src/libstrongswan/bio/bio_reader.c
@@ -36,6 +36,11 @@ struct private_bio_reader_t {
* Remaining data to process
*/
chunk_t buf;
+
+ /**
+ * Optional data to free during destruction
+ */
+ chunk_t cleanup;
};
METHOD(bio_reader_t, remaining, u_int32_t,
@@ -302,6 +307,7 @@ METHOD(bio_reader_t, read_data32, bool,
METHOD(bio_reader_t, destroy, void,
private_bio_reader_t *this)
{
+ free(this->cleanup.ptr);
free(this);
}
@@ -339,3 +345,17 @@ bio_reader_t *bio_reader_create(chunk_t data)
return &this->public;
}
+
+/**
+ * See header
+ */
+bio_reader_t *bio_reader_create_own(chunk_t data)
+{
+ private_bio_reader_t *this;
+
+ this = (private_bio_reader_t*)bio_reader_create(data);
+
+ this->cleanup = data;
+
+ return &this->public;
+}
diff --git a/src/libstrongswan/bio/bio_reader.h b/src/libstrongswan/bio/bio_reader.h
index 3162f3eda..475422428 100644
--- a/src/libstrongswan/bio/bio_reader.h
+++ b/src/libstrongswan/bio/bio_reader.h
@@ -187,7 +187,18 @@ struct bio_reader_t {
/**
* Create a bio_reader instance.
+ *
+ * @param data data buffer, must survive lifetime of reader
+ * @return reader
*/
bio_reader_t *bio_reader_create(chunk_t data);
-#endif /** bio_reader_H_ @}*/
+/**
+ * Create a bio_reader instance owning buffer.
+ *
+ * @param data data buffer, gets freed with destroy()
+ * @return reader
+ */
+bio_reader_t *bio_reader_create_own(chunk_t data);
+
+#endif /** BIO_READER_H_ @}*/