-
-struct Runtime
-{
- size_t permanentStringsLength;
- size_t permanentStringsAllocated;
- char** permanentStrings;
-};
-
-Runtime* Runtime_construct()
-{
- Runtime* result = malloc(sizeof(Runtime));
- result->permanentStringsLength = 0;
- result->permanentStringsAllocated = 0;
- result->permanentStrings = NULL;
- return result;
-}
-
-void Runtime_destruct(Runtime* self)
-{
- free(self->permanentStrings);
- free(self);
-}
-
-void Runtime_addPermanentString(Runtime* self, char* const string)
-{
- // TODO Make this function thread-safe
- if(self->permanentStringsLength == self->permanentStringsAllocated)
- {
- if(self->permanentStringsAllocated == 0)
- {
- self->permanentStringsAllocated = 8;
- }
- else
- {
- self->permanentStringsAllocated = self->permanentStringsAllocated * 2;
- }
-
- self->permanentStrings = realloc(
- self->permanentStrings,
- sizeof(char* const) * self->permanentStringsAllocated
- );
-
- // TODO Handle realloc returning NULL
- }
-
- self->permanentStrings[self->permanentStringsLength] = string;
- self->permanentStringsLength++;
-}
-