summaryrefslogtreecommitdiff
path: root/src/netops.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2011-06-24 18:19:00 +0200
committerCarlos Martín Nieto <carlos@cmartin.tk>2011-06-27 02:09:49 +0200
commitc7c787ce0cd944c0e904d47c5ef1088de2fcf85a (patch)
tree15e04675f3ebdeaa8290687bdee7cddc57fa3bcf /src/netops.c
parentea7a5452f40147a510ae8d9e5805d9252e7ddef9 (diff)
downloadlibgit2-c7c787ce0cd944c0e904d47c5ef1088de2fcf85a.tar.gz
Use gitno_buffer in the git transport
This allows us to leave out the buffer handling logic. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Diffstat (limited to 'src/netops.c')
-rw-r--r--src/netops.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/netops.c b/src/netops.c
index 6c164a960..613226d46 100644
--- a/src/netops.c
+++ b/src/netops.c
@@ -38,7 +38,7 @@
#include "common.h"
#include "netops.h"
-void gitno_buffer_setup(gitno_buffer *buf, void*data, unsigned int len, int fd)
+void gitno_buffer_setup(gitno_buffer *buf, char *data, unsigned int len, int fd)
{
memset(buf, 0x0, sizeof(gitno_buffer));
memset(data, 0x0, len);
@@ -64,17 +64,17 @@ int gitno_recv(gitno_buffer *buf)
}
/* Consume up to ptr and move the rest of the buffer to the beginning */
-void gitno_consume(gitno_buffer *buf, void *ptr)
+void gitno_consume(gitno_buffer *buf, const char *ptr)
{
- int left;
+ int consumed;
assert(ptr - buf->data <= (int) buf->len);
- left = buf->len - (ptr - buf->data);
+ consumed = ptr - buf->data;
- memmove(buf->data, ptr, left);
- memset(ptr, 0x0, left);
- buf->offset = left;
+ memmove(buf->data, ptr, buf->offset - consumed);
+ memset(buf->data + buf->offset, 0x0, buf->len - buf->offset);
+ buf->offset -= consumed;
}
/* Consume const bytes and move the rest of the buffer to the beginning */