From ce05175372a9ddca1a225db0765ace1127a39293 Mon Sep 17 00:00:00 2001 From: Nicholas Date: Fri, 12 Nov 2021 09:22:01 -0800 Subject: chore: simplified organizational structure --- sys/libfmt/buffer.c | 60 ----------------------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 sys/libfmt/buffer.c (limited to 'sys/libfmt/buffer.c') diff --git a/sys/libfmt/buffer.c b/sys/libfmt/buffer.c deleted file mode 100644 index 0099e72..0000000 --- a/sys/libfmt/buffer.c +++ /dev/null @@ -1,60 +0,0 @@ -#include "internal.h" - -static int -flush(fmt·State *io) -{ - int n; - char *s; - - void *heap = io->heap; - mem·Reallocator mem = io->mem; - - if(!io->buffer.beg) - return 0; - - n = 2*(uintptr)io->file; - s = io->buffer.beg; - - io->buffer.beg = mem.realloc(heap, io->buffer.beg, n, 1); - if(!io->buffer.beg){ - io->file = io->buffer.cur = io->buffer.end = nil; - mem.free(heap, s); - return 0; - } - io->file = (void*)(uintptr)n; - io->buffer.cur = io->buffer.beg + (io->buffer.cur - s); - io->buffer.end = io->buffer.beg + n - 1; - - return 1; -} - -int -fmt·make(mem·Reallocator mem, void *heap, fmt·State *io) -{ - int n; - - memset(io, 0, sizeof(*io)); - - n = 32; - io->buffer.beg = io->buffer.cur = mem.alloc(heap, n, 1); - if(!io->buffer.beg) - return -1; - io->buffer.end = io->buffer.beg + n - 1; - - io->flush = flush; - io->file = (void*)(uintptr)n; - io->n = 0; - - fmt·setlocale(io, nil, nil, nil); - return 0; -} - -void -fmt·free(fmt·State *io) -{ - void *heap = io->heap; - mem·Reallocator mem = io->mem; - - mem.free(heap, io->buffer.beg); - io->buffer.beg = io->buffer.cur = io->buffer.end = nil; -} -- cgit v1.2.1