Merge branch 'pt-tls'

This commit is contained in:
Martin Willi
2013-02-14 17:06:07 +01:00
20 changed files with 1414 additions and 95 deletions
+20
View File
@@ -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;
}
+12 -1
View File
@@ -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_ @}*/
+5
View File
@@ -190,6 +190,11 @@ static inline void chunk_clear(chunk_t *chunk)
*/
#define chunk_from_thing(thing) chunk_create((char*)&(thing), sizeof(thing))
/**
* Initialize a chunk from a static string, not containing 0-terminator
*/
#define chunk_from_str(str) chunk_create(str, strlen(str))
/**
* Allocate a chunk on the heap
*/