aboutsummaryrefslogtreecommitdiff
path: root/sys/libn/memory.c
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2021-09-08 15:51:40 -0700
committerNicholas Noll <nbnoll@eml.cc>2021-09-08 15:51:53 -0700
commitc0a7b53baf2a6e7bf9bc1fbec7ac05e43ac59154 (patch)
tree385b83f4d505da960820932f7357eb46b31abac3 /sys/libn/memory.c
parent8c0475f97675245d1bcbb112dc79c9f490fad361 (diff)
checkin
Diffstat (limited to 'sys/libn/memory.c')
-rw-r--r--sys/libn/memory.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/sys/libn/memory.c b/sys/libn/memory.c
index d7df8e3..1c7ab07 100644
--- a/sys/libn/memory.c
+++ b/sys/libn/memory.c
@@ -36,23 +36,23 @@ mem·Allocator sys·Memory = {
/* Grow to particular size */
void*
-bufgrow(void* buf, vlong newLen, vlong eltsize)
+·bufgrow(void* buf, vlong newLen, vlong eltsize)
{
assert(bufcap(buf) <= (SIZE_MAX - 1) / 2);
vlong newCap = MAX(16, MAX(1 + 2 * bufcap(buf), newLen));
assert(newLen <= newCap);
- assert(newCap <= (SIZE_MAX - offsetof(bufHdr, buf)) / eltsize);
+ assert(newCap <= (SIZE_MAX - offsetof(BufHdr, buf)) / eltsize);
- vlong newSize = offsetof(bufHdr, buf) + newCap * eltsize;
+ vlong newSize = offsetof(BufHdr, buf) + newCap * eltsize;
- bufHdr* newHdr;
+ BufHdr* newHdr;
if (buf) {
- newHdr = _bufHdr(buf);
- newHdr = (bufHdr*)realloc((void*)newHdr, newSize);
+ newHdr = bufhdr(buf);
+ newHdr = (BufHdr*)realloc((void*)newHdr, newSize);
} else {
- newHdr = (bufHdr*)malloc(newSize);
+ newHdr = (BufHdr*)malloc(newSize);
newHdr->len = 0;
}
@@ -62,20 +62,20 @@ bufgrow(void* buf, vlong newLen, vlong eltsize)
/* Pop out a value */
void
-_bufpop(void *buf, int i, vlong eltsize)
+·bufdel(void *buf, int i, vlong eltsize)
{
int n;
byte *b;
byte stk[1024];
assert(eltsize < sizeof(stk));
- b = (byte*) buf;
- if (n = buflen(buf), i < n) {
+ b = (byte*)buf;
+ if(n = buflen(buf), i < n) {
memcpy(stk, b+eltsize*i, eltsize);
memcpy(b+eltsize*i, b+eltsize*(i+1), eltsize*(n-i-1));
memcpy(b+eltsize*(n-1), stk, eltsize);
}
- _bufHdr(buf)->len--;
+ bufhdr(buf)->len--;
}
// -------------------------------------------------------------------------