KrkValueArray Struct Reference

Flexible vector of stack references. More...

#include <value.h>

Public Member Functions

void krk_initValueArray (KrkValueArray *array)
 Initialize a value array. More...
 
void krk_writeValueArray (KrkValueArray *array, KrkValue value)
 Add a value to a value array. More...
 
void krk_freeValueArray (KrkValueArray *array)
 Release relesources used by a value array. More...
 

Data Fields

size_t capacity
 
size_t count
 
KrkValuevalues
 

Detailed Description

Flexible vector of stack references.

Value Arrays provide a resizable collection of values and are the backbone of lists and tuples.

Definition at line 75 of file value.h.

Member Function Documentation

◆ krk_freeValueArray()

void krk_freeValueArray ( KrkValueArray array)

Release relesources used by a value array.

Frees the storage associated with a given value array and resets its capacity and count. Does not directly free resources associated with heap objects referenced by the values in this array: The GC is responsible for taking care of that.

Parameters
arrayArray to release.

Definition at line 28 of file value.c.

◆ krk_initValueArray()

void krk_initValueArray ( KrkValueArray array)

Initialize a value array.

This should be called for any new value array, especially ones initialized in heap or stack space, to set up the capacity, count and initial value pointer.

Parameters
arrayValue array to initialize.

Definition at line 11 of file value.c.

◆ krk_writeValueArray()

void krk_writeValueArray ( KrkValueArray array,
KrkValue  value 
)

Add a value to a value array.

Appends 'value' to the end of the given array, adjusting count values and resizing as necessary.

Parameters
arrayArray to append to.
valueValue to append to array.

Definition at line 17 of file value.c.

Field Documentation

◆ capacity

size_t KrkValueArray::capacity

Available allocated space.

Definition at line 76 of file value.h.

◆ count

size_t KrkValueArray::count

Current number of used slots.

Definition at line 77 of file value.h.

◆ values

KrkValue* KrkValueArray::values

Pointer to heap-allocated storage.

Definition at line 78 of file value.h.


The documentation for this struct was generated from the following file: