Toy_String now fragments strings that are too long

This commit is contained in:
2024-10-12 20:20:19 +11:00
parent c1d72adb71
commit 7b1dbf25ff
4 changed files with 91 additions and 35 deletions

View File

@@ -5,9 +5,6 @@
#include "toy_bucket.h"
#include "toy_value.h"
//TODO: Remove this (related to partitioning more space in a bucket issue)
#define TOY_STRING_MAX_LENGTH 1000
//rope pattern
typedef struct Toy_String { //32 | 64 BITNESS
enum Toy_StringType {
@@ -39,7 +36,7 @@ typedef struct Toy_String { //32 | 64 BITNESS
} Toy_String; //24 | 32
TOY_API Toy_String* Toy_createString(Toy_Bucket** bucketHandle, const char* cstring);
TOY_API Toy_String* Toy_createStringLength(Toy_Bucket** bucketHandle, const char* cstring, int length);
TOY_API Toy_String* Toy_createStringLength(Toy_Bucket** bucketHandle, const char* cstring, unsigned int length);
TOY_API Toy_String* Toy_createNameString(Toy_Bucket** bucketHandle, const char* cname, Toy_ValueType type); //for variable names
@@ -50,8 +47,8 @@ TOY_API Toy_String* Toy_concatStrings(Toy_Bucket** bucketHandle, Toy_String* lef
TOY_API void Toy_freeString(Toy_String* str);
TOY_API int Toy_getStringLength(Toy_String* str);
TOY_API int Toy_getStringRefCount(Toy_String* str);
TOY_API unsigned int Toy_getStringLength(Toy_String* str);
TOY_API unsigned int Toy_getStringRefCount(Toy_String* str);
TOY_API char* Toy_getStringRawBuffer(Toy_String* str); //allocates the buffer on the heap, needs to be freed