Fix: Don't allocate buffers if we don't need to

This commit is contained in:
Denis Kenzior 2010-02-26 16:16:46 -06:00
parent c6f4d051b2
commit 988fed5951
1 changed files with 6 additions and 1 deletions

View File

@ -136,7 +136,12 @@ static void send_common(GAtServer *server, const char *buf, unsigned int len)
buf + bytes_written,
wbytes);
if (ring_buffer_avail(write_buf) == 0)
/*
* Make sure we don't allocate a buffer if we've written
* everything out already
*/
if (ring_buffer_avail(write_buf) == 0 &&
bytes_written < towrite)
write_buf = allocate_next(server);
}