mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 12:00:56 +01:00
finally fixed all stream related problems, z85 transparent en/decoding works, unittests all ok.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user