@@ -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