Mid-work through documenting darr.h
This commit is contained in:
15
lib/darr.h
15
lib/darr.h
@@ -18,14 +18,29 @@
|
|||||||
|
|
||||||
#include "./base.h"
|
#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
|
typedef struct
|
||||||
{
|
{
|
||||||
byte *data;
|
byte *data;
|
||||||
size_t used, available;
|
size_t used, available;
|
||||||
} darr_t;
|
} darr_t;
|
||||||
|
|
||||||
|
/* Some useful constants for dynamic array work. */
|
||||||
#define DARR_DEFAULT_SIZE 8
|
#define DARR_DEFAULT_SIZE 8
|
||||||
#define DARR_REALLOC_MULT 1.5
|
#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)]
|
#define DARR_AT(TYPE, DARR_DATA, IND) ((TYPE *)(DARR_DATA))[(IND)]
|
||||||
|
|
||||||
void darr_init(darr_t *, size_t);
|
void darr_init(darr_t *, size_t);
|
||||||
|
|||||||
2
todo.org
2
todo.org
@@ -6,7 +6,7 @@
|
|||||||
** TODO Comment coverage [0%]
|
** TODO Comment coverage [0%]
|
||||||
*** WIP Lib [25%]
|
*** WIP Lib [25%]
|
||||||
**** DONE lib/base.h
|
**** DONE lib/base.h
|
||||||
**** TODO lib/darr.h
|
**** WIP lib/darr.h
|
||||||
**** TODO lib/heap.h
|
**** TODO lib/heap.h
|
||||||
**** TODO lib/inst.h
|
**** TODO lib/inst.h
|
||||||
*** TODO ASM [0%]
|
*** TODO ASM [0%]
|
||||||
|
|||||||
Reference in New Issue
Block a user