aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/mem.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/lib/mem.c b/src/lib/mem.c
index dc915e6..e51ec32 100644
--- a/src/lib/mem.c
+++ b/src/lib/mem.c
@@ -5,13 +5,15 @@ void memcpyrot(unsigned char* src, struct RotBuffer* rb, unsigned int n)
{
if (n > rb->size)
return;
- unsigned char* addr = rb->base + rb->offset;
+ unsigned char* base = rb->base;
+ unsigned int offset = rb->woffset;
for (unsigned int i = 0; i < n; i++) {
- if (addr >= (unsigned char*)(rb->base + rb->size))
- addr = rb->base;
- *addr = src[i];
- addr++;
+ if (offset >= rb->size)
+ offset = 0;
+ base[offset] = src[i];
+ offset++;
}
+ rb->woffset = offset;
}
void memshow32(unsigned long* addr, unsigned int n)