aboutsummaryrefslogtreecommitdiffhomepage
path: root/io.h
diff options
context:
space:
mode:
authorGravatar Cheer Xiao <xiaqqaix@gmail.com>2013-01-17 15:46:10 +0800
committerGravatar Cheer Xiao <xiaqqaix@gmail.com>2013-01-17 15:55:06 +0800
commite0c858478ad564712d9b2a2799abff8496dcc55c (patch)
tree2b54a468a0e03887acb0505d3260eaa1685912b4 /io.h
parenta3b15b995e9448e1ed34b1a9d4d168abdf161b6e (diff)
Revert "Make io_buffer_t::out_buffer a raw pointer, initialize in io_buffer_t's constructor"
This reverts commit d48ffab9d67da48cf45c2f5560c21a767144545f. Conflicts: io.cpp io.h
Diffstat (limited to 'io.h')
-rw-r--r--io.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/io.h b/io.h
index c463836b..bfe910e3 100644
--- a/io.h
+++ b/io.h
@@ -125,11 +125,11 @@ class io_buffer_t : public io_pipe_t
{
private:
/** buffer to save output in */
- std::vector<char> *out_buffer;
+ shared_ptr<std::vector<char> > out_buffer;
io_buffer_t(int f, bool i):
io_pipe_t(IO_BUFFER, f, i),
- out_buffer(new std::vector<char>)
+ out_buffer()
{
}
@@ -138,26 +138,36 @@ public:
virtual ~io_buffer_t();
+ /** Function to create the output buffer */
+ void out_buffer_create()
+ {
+ out_buffer.reset(new std::vector<char>);
+ }
+
/** Function to append to the buffer */
void out_buffer_append(const char *ptr, size_t count)
{
+ assert(out_buffer.get() != NULL);
out_buffer->insert(out_buffer->end(), ptr, ptr + count);
}
/** Function to get a pointer to the buffer */
char *out_buffer_ptr(void)
{
+ assert(out_buffer.get() != NULL);
return out_buffer->empty() ? NULL : &out_buffer->at(0);
}
const char *out_buffer_ptr(void) const
{
+ assert(out_buffer.get() != NULL);
return out_buffer->empty() ? NULL : &out_buffer->at(0);
}
/** Function to get the size of the buffer */
size_t out_buffer_size(void) const
{
+ assert(out_buffer.get() != NULL);
return out_buffer->size();
}