From 5989629a7951e544ad4656672025a99ecd08c7c9 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Sat, 11 Feb 2023 21:31:04 -0800 Subject: Change how slices work. I'm switching to a more macro-heavy solution. Hopefully it proves robust. --- bytecode/bytecode.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'bytecode/bytecode.c') diff --git a/bytecode/bytecode.c b/bytecode/bytecode.c index 1d0f957..9ac4a1e 100644 --- a/bytecode/bytecode.c +++ b/bytecode/bytecode.c @@ -4,27 +4,27 @@ #include "oper.h" #include "panic.h" -#include "slice.h" +#include "byte_slice.h" -static struct slice xrealloc(void *ptr, size_t size) +static uint8_t_slice xrealloc(void *ptr, size_t size) { void *p = realloc(ptr, size); if (!p) { panicf("Out of memory!\n"); } - return (struct slice) { + return (uint8_t_slice) { .buf = p, .size = size, }; } -struct slice read_file(char *filename) +static uint8_t_slice read_file(char *filename) { FILE *f = fopen(filename, "r"); if (!f) { panicf("File %s does not exit!\n", filename); } - struct slice out = { .size = 0, .buf = NULL }; + uint8_t_slice out = { .size = 0, .buf = NULL }; size_t offset = 0; while (true) { if (offset >= out.size) { @@ -37,7 +37,7 @@ struct slice read_file(char *filename) if (ferror(f)) { panicf("Read error!\n"); } - return slice(out, 0, offset + n); + return uint8_t_slice2(out, 0, offset + n); } offset += n; } @@ -50,7 +50,7 @@ int main(int argc, char **argv) return 1; } - struct slice program = read_file(argv[1]); + uint8_t_slice program = read_file(argv[1]); run(program); -- cgit v1.3.1