add slide_write to switch_buffer

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15297 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-10-30 22:53:09 +00:00
parent b1aefe2b6f
commit 41f7ac7387
2 changed files with 14 additions and 0 deletions

View File

@ -137,6 +137,8 @@ SWITCH_DECLARE(switch_size_t) switch_buffer_toss(_In_ switch_buffer_t *buffer, _
*/
SWITCH_DECLARE(void) switch_buffer_zero(_In_ switch_buffer_t *buffer);
SWITCH_DECLARE(switch_size_t) switch_buffer_slide_write(switch_buffer_t *buffer, const void *data, switch_size_t datalen);
/*! \brief Destroy the buffer
* \param buffer buffer to destroy
* \note only neccessary on dynamic buffers (noop on pooled ones)

View File

@ -280,6 +280,18 @@ SWITCH_DECLARE(switch_size_t) switch_buffer_zwrite(switch_buffer_t *buffer, cons
return w;
}
SWITCH_DECLARE(switch_size_t) switch_buffer_slide_write(switch_buffer_t *buffer, const void *data, switch_size_t datalen)
{
switch_size_t w;
if (!(w = switch_buffer_write(buffer, data, datalen))) {
switch_buffer_toss(buffer, datalen);
return switch_buffer_write(buffer, data, datalen);
}
return w;
}
SWITCH_DECLARE(void) switch_buffer_destroy(switch_buffer_t **buffer)
{
if (buffer && *buffer) {