diff options
Diffstat (limited to 'src/io.c')
| -rw-r--r-- | src/io.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -91,7 +91,7 @@ void stream_dump(FILE *fp, struct stream *s, size_t n) { /* Copies `n` bytes into the given stream from the memory area specified by `src`. The stream's cursor is advanced appropriately. */ void stream_write(struct stream *s, void *src, size_t n) { - if (s->_cur + n > s->_start + s->len) { + while (s->_cur + n > s->_start + s->len) { ptrdiff_t dist = (uintptr_t) s->_cur - (uintptr_t) s->_start; switch(s->_loc) { case HEAP: @@ -105,6 +105,12 @@ void stream_write(struct stream *s, void *src, size_t n) { } +/* Concatenats the contents of `src` onto `dst`. */ +void stream_concat(struct stream *dst, struct stream *src, size_t n) { + stream_write(dst, src->_cur, n); +} + + /* Applies an initial and primary key to the given stream, effectively encrypting or decrypting it. */ void stream_xor(struct stream *s, uint8_t initial, uint8_t primary) { |