diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-04-09 21:21:12 +0630 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-04-09 21:21:12 +0630 |
commit | d256e06f518d701413dfb9bff6d00504f8c88109 (patch) | |
tree | 6b89608be190427cbe3ad7bf6b0a724f3391170b | |
parent | 84028dab79bc42bb4aa01e59dac57294ef816649 (diff) | |
download | ovm-d256e06f518d701413dfb9bff6d00504f8c88109.tar.gz ovm-d256e06f518d701413dfb9bff6d00504f8c88109.tar.bz2 ovm-d256e06f518d701413dfb9bff6d00504f8c88109.zip |
Mid-work through documenting darr.h
-rw-r--r-- | lib/darr.h | 19 | ||||
-rw-r--r-- | todo.org | 2 |
2 files changed, 18 insertions, 3 deletions
@@ -18,14 +18,29 @@ #include "./base.h" +/** + * A dynamically sized buffer of bytes which may be used for a + * variety of purposes. + * @prop data: Buffer of bytes (may be reallocated) + * @prop used: Number of bytes currently used + * @prop available: Number of bytes currently allocated + */ typedef struct { byte *data; size_t used, available; } darr_t; -#define DARR_DEFAULT_SIZE 8 -#define DARR_REALLOC_MULT 1.5 +/* Some useful constants for dynamic array work. */ +#define DARR_DEFAULT_SIZE 8 +#define DARR_REALLOC_MULT 1.5 + +/** Get the INDth item in a darr, where the buffer of bytes is + * considerd an array of type TYPE. + * Unsafe operation as safety checks are not done (in particular if + * the dynamic array has IND items or is big enough to store an + * element of TYPE) so it is presumed the caller will. + */ #define DARR_AT(TYPE, DARR_DATA, IND) ((TYPE *)(DARR_DATA))[(IND)] void darr_init(darr_t *, size_t); @@ -6,7 +6,7 @@ ** TODO Comment coverage [0%] *** WIP Lib [25%] **** DONE lib/base.h -**** TODO lib/darr.h +**** WIP lib/darr.h **** TODO lib/heap.h **** TODO lib/inst.h *** TODO ASM [0%] |