mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 05:28:49 +00:00
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
This commit is contained in:
parent
a3b15b995e
commit
e0c858478a
2 changed files with 13 additions and 3 deletions
2
io.cpp
2
io.cpp
|
@ -135,6 +135,7 @@ io_buffer_t *io_buffer_t::create(bool is_input)
|
|||
{
|
||||
bool success = true;
|
||||
io_buffer_t *buffer_redirect = new io_buffer_t(is_input ? 0 : 1, is_input);
|
||||
buffer_redirect->out_buffer_create();
|
||||
|
||||
if (exec_pipe(buffer_redirect->pipe_fd) == -1)
|
||||
{
|
||||
|
@ -163,7 +164,6 @@ io_buffer_t *io_buffer_t::create(bool is_input)
|
|||
io_buffer_t::~io_buffer_t()
|
||||
{
|
||||
|
||||
delete out_buffer;
|
||||
/**
|
||||
If this is an input buffer, then io_read_buffer will not have
|
||||
been called, and we need to close the output fd as well.
|
||||
|
|
14
io.h
14
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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue