Add lists (MEMORY ERRORS)

This commit is contained in:
2025-12-01 10:15:37 +11:00
parent 0b917a6702
commit 6eeccf58fe
5 changed files with 202 additions and 16 deletions

View File

@@ -27,6 +27,16 @@ struct GroundValue;
struct List;
/*
* Custom data type that stores Ground values.
* Associated functions:
* createList(), appendToList(), getListAt(), setListAt()
*/
typedef struct List {
size_t size;
struct GroundValue* values;
} List;
/*
* Stores literal values created in a Ground program.
* Associated functions:
@@ -41,21 +51,11 @@ typedef struct GroundValue {
char* stringVal;
char charVal;
bool boolVal;
struct List* listVal;
List listVal;
void* customVal;
} data;
} GroundValue;
/*
* Custom data type that stores Ground values.
* Associated functions:
* createList(), appendToList(), getListAt(), setListAt()
*/
typedef struct List {
size_t size;
GroundValue* values;
} List;
/*
* Indicates status when accessing a list.
* Associated functions:
@@ -107,6 +107,9 @@ GroundValue createCharGroundValue(char in);
// Creates a GroundValue containing (in), with type BOOl.
GroundValue createBoolGroundValue(bool in);
// Creates a GroundValue containing (in), with type LIST.
GroundValue createListGroundValue(List in);
// If (gv) contains any data stored on the heap, frees it.
void freeGroundValue(GroundValue* gv);