Convenience functions for a C byte slice
typedef struct snns_Slice
{
void *arr;
size_t cap;
} snns_Slice;
The script make_and_test.sh
compiles with address- and memory-sanitizer and runs through the tests specified in test.c
All functions are described in more detail in snns_slice.h
//Returns an initialized slice
snns_Slice snns_Slice_makeNew(void);
//Initialized an existing slice
void snns_Slice_doInit(snns_Slice*);
//Tests if a slice is initialized
bool snns_Slice_isInit(snns_Slice*);
//Sets all allocated bytes to zero
void snns_Slice_doClear(snns_Slice*);
//Tests if all allocated bytes are zero
bool snns_Slice_isClear_linearN(snns_Slice*);
//Allocates a zeroed out array of bytes to the slice
snns_Slice_Result snns_Slice_calloc(snns_Slice*, size_t);
//Re-allocates a slice if it is shorter than requested
snns_Slice_Result snns_Slice_calloc(snns_Slice*, size_t);
//Deallocates a slice and sets it to the Init state
void snns_Slice_dealloc(snns_Slice*);
//Overwrites content of first slice with content of second slice
snns_Slice_Result snns_Slice_copy(snns_Slice*, snns_Slice*);
//Appends content of second slice to first slice
snns_Slice_Result snns_Slice_append(snns_Slice*, snns_Slice*);