finally fixed all stream related problems, z85 transparent en/decoding works, unittests all ok.

This commit is contained in:
git@daemon.de
2014-02-27 13:55:43 +01:00
parent c11ce76d21
commit 97f4d14d3b
17 changed files with 209 additions and 68 deletions

View File

@@ -125,11 +125,16 @@ byte *buffer_get(Buffer *b) {
}
size_t buffer_get_chunk(Buffer *b, void *buf, size_t len) {
if(len > b->end - b->offset || len == 0) {
if(len > b->end - b->offset) {
fatal("[buffer %s] attempt to read %ld bytes data from buffer with %ld bytes left at offset %ld\n",
b->name, len, b->end - b->offset, b->offset);
return 0;
}
else if(len == 0) {
/* FIXME: check how this happens */
return 0;
}
memcpy(buf, b->buf + b->offset, len);
b->offset += len;
@@ -137,11 +142,15 @@ size_t buffer_get_chunk(Buffer *b, void *buf, size_t len) {
}
size_t buffer_get_chunk_tobuf(Buffer *b, Buffer *dst, size_t len) {
if(len > b->end - b->offset || len == 0) {
if(len > b->end - b->offset) {
fatal("[buffer %s] attempt to read %ld bytes data from buffer with %ld bytes left at offset %ld\n",
b->name, len, b->end - b->offset, b->offset);
return 0;
}
else if(len == 0) {
/* FIXME: check how this happens */
return 0;
}
buffer_resize(dst, len);
memcpy(dst->buf+buffer_size(dst), b->buf + b->offset, len);