Implement string space pool with compacting garbage collector
Replaces individual malloc/free string management with a contiguous pool
(default 32KB) and compacting GC, matching the original GW-BASIC's
GETSPA/GARBAG architecture. Allocation is a bump pointer; gw_str_free()
is a no-op (descriptors are nulled, data reclaimed by GC). Compaction
runs at statement boundaries when the pool drops below 4KB free, walking
the variable table and array storage to relocate live strings.
FRE() now returns actual free pool space. FRE("") triggers a GC pass
before reporting. CLEAR n sets the string space size.
This commit is contained in:
+1
-1
@@ -16,7 +16,7 @@ typedef enum {
|
||||
/* String descriptor - matches original's 3-byte layout concept */
|
||||
typedef struct {
|
||||
uint8_t len;
|
||||
char *data; /* malloc'd, NOT null-terminated */
|
||||
char *data; /* points into string pool, NOT null-terminated */
|
||||
} gw_string_t;
|
||||
|
||||
/* Unified value - the FAC (floating accumulator) equivalent */
|
||||
|
||||
Reference in New Issue
Block a user