From 43ecfce7d20360a5fdc53e5ced266eccc8723242 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Fri, 29 May 2020 14:41:05 -0700 Subject: blas code update --- include/libn.h | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'include/libn.h') diff --git a/include/libn.h b/include/libn.h index 835d2c1..721defd 100644 --- a/include/libn.h +++ b/include/libn.h @@ -65,21 +65,17 @@ typedef struct mem·Allocator { void (*free)(void *iface, void *ptr); } mem·Allocator; -/* system implementation */ -static -void ·free(void* _, void* ptr) { - return free(ptr); -} - -static -void *·alloc(void* _, uint n, ulong size) { - return malloc(n*size); -} +typedef struct mem·Reallocator { + void *(*alloc)(void *iface, uint n, ulong size); + void *(*realloc)(void *iface, void *ptr, uint n, ulong size); + void (*free)(void *iface, void *ptr); +} mem·Reallocator; -static -void *·calloc(void* _, uint n, ulong size) { - return calloc(n, size); -} +/* system implementation */ +extern void ·free(void* _, void *ptr); +extern void *·alloc(void* _, uint n, ulong size); +extern void *·calloc(void* _, uint n, ulong size); +extern void *·realloc(void* _, void *ptr, uint n, ulong size); // TODO(nnoll): Allow for nil iterfaces? static @@ -123,10 +119,10 @@ int str·cap(const string s); void str·clear(string *s); void str·grow(string *s, vlong delta); void str·fit(string *s); -void str·appendlen(string *s, vlong len, const byte *b); -void str·append(string *s, const byte* b); -void str·appendf(string *s, const byte* fmt, ...); -void str·appendbyte(string *s, const byte b); +int str·appendlen(string *s, vlong len, const byte *b); +int str·append(string *s, const byte* b); +int str·appendf(string *s, const byte* fmt, ...); +int str·appendbyte(string *s, const byte b); bool str·equals(const string s, const string t); int str·find(string s, const byte* substr); void str·lower(string s); @@ -344,9 +340,9 @@ vlong gz·seek(gz·Stream *s, long off, enum SeekPos whence); // ----------------------------------------------------------------------------- // error handling functions -void errorf(const byte* fmt, ...); - -#define panicf(...) (errorf(__VA_ARGS__), assert(0)) +void errorf(byte* fmt, ...); +void panicf(byte *fmt, ...); +void vpanicf(byte *fmt, va_list args); // ----------------------------------------------------------------------------- // sorting -- cgit v1.2.1