Sp I have a function like:
void WriteToUrl(const unsigned char *buf, int size)
{
boost::asio::write(s, boost::asio::buffer(buf, size));
}
Do I need to delete buffer if I do not use it any where else? How do I need to clean after y function?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If I have understood you are always the ownership of the buffer ‘buf’. With synchronous operations, as ::write, you can delete the buffer as soon as ::write finish. With asynchronous operations, as ::async_write, you need to give an asynchronous completion token (a callback) which will be called when the operation has been done. The you could delete the buf in this callback.