Convert io_buffer_destroy to ~io_buffer_t

This commit is contained in:
Cheer Xiao 2013-01-15 17:02:46 +08:00
parent a20e0b9e2e
commit 0f443ef37b
4 changed files with 6 additions and 15 deletions

View file

@ -1054,8 +1054,6 @@ void exec(parser_t &parser, job_t *j)
p->completed = 1;
}
io_buffer_destroy(io_buffer);
io_buffer.reset();
break;
@ -1455,7 +1453,6 @@ static int exec_subshell_internal(const wcstring &cmd, wcstring_list_t *lst)
}
}
io_buffer_destroy(io_buffer);
return status;
}

8
io.cpp
View file

@ -161,19 +161,19 @@ io_buffer_t *io_buffer_create(bool is_input)
return buffer_redirect;
}
void io_buffer_destroy(const shared_ptr<io_buffer_t> &io_buffer)
io_buffer_t::~io_buffer_t()
{
/**
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.
*/
if (io_buffer->is_input)
if (is_input)
{
exec_close(io_buffer->param1.pipe_fd[1]);
exec_close(param1.pipe_fd[1]);
}
exec_close(io_buffer->param1.pipe_fd[0]);
exec_close(param1.pipe_fd[0]);
/*
Dont free fd for writing. This should already be free'd before

7
io.h
View file

@ -128,6 +128,8 @@ public:
{
}
~io_buffer_t();
/** Function to create the output buffer */
void out_buffer_create()
{
@ -199,11 +201,6 @@ shared_ptr<const io_data_t> io_chain_get(const io_chain_t &src, int fd);
shared_ptr<io_data_t> io_chain_get(io_chain_t &src, int fd);
/**
Free all resources used by a IO_BUFFER type io redirection.
*/
void io_buffer_destroy(const shared_ptr<io_buffer_t> &io_buffer);
/**
Create a IO_BUFFER type io redirection, complete with a pipe and a
vector<char> for output. The default file descriptor used is 1 for

View file

@ -1158,9 +1158,6 @@ static void run_pager(const wcstring &prefix, int is_quoted, const std::vector<c
input_unreadch(str.at(idx));
}
}
io_buffer_destroy(out);
io_buffer_destroy(in);
}
struct autosuggestion_context_t