From c0a7b53baf2a6e7bf9bc1fbec7ac05e43ac59154 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Wed, 8 Sep 2021 15:51:40 -0700 Subject: checkin --- sys/libn/memory.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'sys/libn/memory.c') 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--; } // ------------------------------------------------------------------------- -- cgit v1.2.1