Skip to content

Commit 175106b

Browse files
wty tf did i have a 64mb string area
1 parent 92d6d75 commit 175106b

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

include/string.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#pragma once
88
#include "basic.h"
99

10-
#define STRING_GC_AREA_SIZE (64 * 1024 * 1024)
10+
#define STRING_GC_AREA_SIZE (128 * 1024)
1111

1212
/**
1313
* @brief Linked list node for garbage-collected strings.

src/basic/main.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ struct basic_ctx *basic_init(const char *program, uint32_t pid, const char *file
253253

254254
ctx->allocator = kmalloc(sizeof(buddy_allocator_t));
255255
if (!ctx->allocator) {
256-
kfree_null(&ctx->program_ptr);
256+
buddy_free(ctx->allocator, ctx->program_ptr);
257257
kfree_null(&ctx);
258258
*error = "Out of memory";
259259
return NULL;
@@ -288,15 +288,15 @@ struct basic_ctx *basic_init(const char *program, uint32_t pid, const char *file
288288
memset(ctx->local_double_variables, NULL, sizeof(ctx->local_double_variables));
289289
// We allocate 5000 bytes extra on the end of the program for EVAL space,
290290
// as EVAL appends to the program on lines EVAL_LINE and EVAL_LINE + 1.
291-
ctx->program_ptr = kmalloc(strlen(program) + 5000);
291+
ctx->program_ptr = buddy_malloc(ctx->allocator, strlen(program) + 5000);
292292
if (ctx->program_ptr == NULL) {
293293
kfree_null(&ctx);
294294
*error = "Out of memory";
295295
return NULL;
296296
}
297-
ctx->string_gc_storage = kmalloc(STRING_GC_AREA_SIZE);
297+
ctx->string_gc_storage = buddy_malloc(ctx->allocator, STRING_GC_AREA_SIZE);
298298
if (!ctx->string_gc_storage) {
299-
kfree_null(&ctx->program_ptr);
299+
buddy_free(ctx->allocator, ctx->program_ptr);
300300
kfree_null(&ctx);
301301
*error = "Out of memory";
302302
return NULL;
@@ -410,7 +410,7 @@ void library_statement(struct basic_ctx *ctx) {
410410
* ctx->program_ptr invalidating ctx->ptr and ctx->next_ptr - the tokeinizer
411411
* must be reinitailised and the line hash rebuilt)
412412
*/
413-
ctx->program_ptr = krealloc(ctx->program_ptr, strlen(ctx->program_ptr) + 5000 + library_len);
413+
ctx->program_ptr = buddy_realloc(ctx->allocator, ctx->program_ptr, strlen(ctx->program_ptr) + 5000 + library_len);
414414
if (!ctx->program_ptr) {
415415
tokenizer_error_printf(ctx, "Not enough memory to load library file '%s'", lib_file);
416416
kfree_null(&numbered);
@@ -530,14 +530,10 @@ void basic_destroy(struct basic_ctx *ctx) {
530530
free_sprite(ctx, sprite_handle);
531531
}
532532
}
533-
kfree_null(&ctx->string_gc_storage);
534533
ctx->string_gc_storage_next = NULL;
535-
hashmap_free(ctx->lines);
536-
basic_free_defs(ctx);
537534
/* I'm not your pal, buddy... 😂 */
538535
buddy_destroy(ctx->allocator);
539536
kfree_null(&ctx->allocator);
540-
kfree_null(&ctx->program_ptr);
541537
kfree_null(&ctx);
542538
}
543539

0 commit comments

Comments
 (0)