mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Implemented and tested Toy_String, read more
Strings are needed for the handling of identifiers in the key/value variable storage, so I've got them working first. I used the rope pattern, which seems to be quite an interesting approach. I'll add comparison checks later. Adjusted how buckets are handled in all tests, could've been an issue down the line. Added the build instructions to README.md.
This commit is contained in:
@@ -28,7 +28,7 @@ void Toy_initBucket(Toy_Bucket** bucketHandle, size_t capacity) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
(*bucketHandle) = malloc(sizeof(Toy_Bucket));
|
||||
(*bucketHandle) = malloc(sizeof(Toy_Bucket)); //TODO: rework the bucket, so there's only one malloc() call instead of two when partitioning
|
||||
|
||||
if ((*bucketHandle) == NULL) {
|
||||
fprintf(stderr, TOY_CC_ERROR "[internal] ERROR: Failed to allocate space for a bucket\n" TOY_CC_RESET);
|
||||
@@ -48,6 +48,12 @@ void* Toy_partBucket(Toy_Bucket** bucketHandle, size_t space) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//if you try to allocate too much space
|
||||
if ((*bucketHandle)->capacity < space) {
|
||||
fprintf(stderr, TOY_CC_ERROR "[internal] ERROR: Failed to partition bucket memory, not enough capacity\n" TOY_CC_RESET);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//if out of space in the current bucket
|
||||
if ((*bucketHandle)->capacity < (*bucketHandle)->count + space) {
|
||||
//move to the next bucket
|
||||
|
||||
Reference in New Issue
Block a user