Commit 7c7ba170 authored by Niels Möller's avatar Niels Möller
Browse files

*** empty log message ***

Rev: src/write_buffer.c:1.2
parent b1afd313
...@@ -11,7 +11,7 @@ static int do_write(struct write_buffer *closure, ...@@ -11,7 +11,7 @@ static int do_write(struct write_buffer *closure,
if (!packet->length) if (!packet->length)
{ {
lsh_string_free(packet); lsh_string_free(packet);
return; return 1;
} }
/* Enqueue packet */ /* Enqueue packet */
...@@ -37,17 +37,24 @@ static int do_write(struct write_buffer *closure, ...@@ -37,17 +37,24 @@ static int do_write(struct write_buffer *closure,
} }
#endif #endif
buffer->empty = 0;
return 1; return 1;
} }
/* Copy data as necessary, before writing. /* Copy data as necessary, before writing.
* *
* FIXME: Writing of large packets could probably be optimized by * FIXME: Writing of large packets could probably be optimized by
* avoiding copying it into the buffer. */ * avoiding copying it into the buffer.
void write_buffer_pre_write(struct write_buffer *buffer) *
* Returns 1 if the buffer is non-empty. */
int write_buffer_pre_write(struct write_buffer *buffer)
{ {
UINT32 length = buffer->end - buffer->start; UINT32 length = buffer->end - buffer->start;
if (buffer->empty)
return 0;
if (buffer->start > buffer->block_size) if (buffer->start > buffer->block_size)
{ {
/* Copy contents to the start of the buffer */ /* Copy contents to the start of the buffer */
...@@ -106,9 +113,10 @@ void write_buffer_pre_write(struct write_buffer *buffer) ...@@ -106,9 +113,10 @@ void write_buffer_pre_write(struct write_buffer *buffer)
} }
} }
buffer->empty = !length; buffer->empty = !length;
return !buffer->empty;
} }
struct write_buffer *write_buffer_alloc(UINT32 size) struct abstract_write *write_buffer_alloc(UINT32 size)
{ {
struct write_buffer *res = xalloc(sizeof(write_callback) - 1 + size*2); struct write_buffer *res = xalloc(sizeof(write_callback) - 1 + size*2);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment