buffer_get_remainder() return pointer to chunk, not allocated copy anymore

This commit is contained in:
TLINDEN
2014-08-07 00:02:05 +02:00
parent 5b4d04de5d
commit 8954df7110

View File

@@ -176,14 +176,12 @@ size_t buffer_get_chunk_tobuf(Buffer *b, Buffer *dst, size_t len) {
} }
byte *buffer_get_remainder(Buffer *b) { byte *buffer_get_remainder(Buffer *b) {
void *buf = ucmalloc(b->end - b->offset); if(buffer_left(b) == 0)
if(buffer_get_chunk(b, buf, b->end - b->offset) == 0) {
free(buf);
return NULL; return NULL;
}
else { else {
return buf; byte *buf = b->buf;
} return &buf[b->offset];
}
} }
uint8_t buffer_get8(Buffer *b) { uint8_t buffer_get8(Buffer *b) {