From b364a39849fc4a6f6837f8558b7520efc24ae96c Mon Sep 17 00:00:00 2001 From: Carson Fleming Date: Sun, 25 Jan 2026 16:00:20 -0500 Subject: bring in some library functions and restructure --- array.h | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'array.h') diff --git a/array.h b/array.h index 5634dc7..ded3216 100644 --- a/array.h +++ b/array.h @@ -1,6 +1,6 @@ #ifndef __SAFEC_ARRAY_H #define __SAFEC_ARRAY_H -#include +#include "types.h" typedef struct { size_t length; @@ -8,20 +8,12 @@ typedef struct { void* __data; } array_t; -void* array_at(const array_t* array, size_t idx); +void* array_at(const array_t array, size_t idx); +array_t array_slice(const array_t array, size_t start, size_t length); -typedef struct { - size_t length; - char* __data; -} str_t; +array_t array_init(void* data, size_t length, size_t elemsz); -char* str_at(const str_t* str, size_t idx); -str_t str_slice(const str_t* str, size_t start, size_t length); -void str_c_str( - char* dst, - size_t dst_size, - const str_t* src -); +array_t array_heap_alloc(size_t length, size_t elemsz); +void array_heap_destroy(array_t array); -/* TODO: reimplement string.h functions for this new string construct */ #endif -- cgit v1.2.3