Files
gw-basic-2026/include/strpool.h
Eremey Valetov 20ecdae938 Add --warn and --safe memory safety flags to the compiler
Three progressive levels for gwbasic-compile:

--warn: static analysis warnings (uninitialized variables, GOTO to
nonexistent line, unreachable code detection). Zero runtime cost.

--safe (implies --warn): runtime checked integer arithmetic via
gw_int_add/sub/mul/neg matching real GW-BASIC overflow semantics,
enhanced array bounds diagnostics with variable names and line numbers,
GOSUB stack overflow diagnostics with source line reporting.

--safe=sanitize (implies --safe): passes -fsanitize=address,undefined
to gcc for full memory error detection.

Also: fix pre-existing missing closing paren in array LET-to-integer
codegen, add strpool_pin/unpin infrastructure, add compiler optimization
flags and memory safety sections to roadmap.

72/72 interpreter tests pass. 64/64 eligible compiler tests pass in
--safe mode.
2026-04-09 13:14:26 -04:00

21 lines
817 B
C

#ifndef STRPOOL_H
#define STRPOOL_H
#include <stddef.h>
#include <stdbool.h>
#define STRPOOL_DEFAULT_SIZE (32 * 1024) /* 32KB — generous vs original's ~3KB */
#define STRPOOL_GC_THRESHOLD 4096 /* GC when less than 4KB free */
void strpool_init(size_t size);
void strpool_shutdown(void);
void strpool_reset(size_t size); /* resize and clear (0 = keep current size) */
char *strpool_alloc(int len); /* bump-allocate from pool */
void strpool_gc(void); /* compact: walk vars+arrays, squeeze out dead space */
size_t strpool_free(void); /* bytes available */
bool strpool_owns(const char *p); /* true if p points into the pool */
void strpool_pin(void); /* prevent GC from running (nestable) */
void strpool_unpin(void); /* allow GC again */
#endif