aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2022-01-20 18:55:23 -0700
committerChristian Cunningham <cc@localhost>2022-01-20 18:55:23 -0700
commit22297e0f0f5732b852614c7c97e7354d3e7be5c7 (patch)
treeaa7bab14241bf97d4073e2d7d1cffea32b3ac03b /src/lib
parent4bb5f36b8c696361d5a283680ea7dadde4e364df (diff)
Added write offset
Made offsets movable
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)