Add debugging validation for quotations and stack operations; enhances integrity checks during push and pop actions.
h3rald h3rald@h3rald.com
Wed, 10 Sep 2025 18:16:55 +0200
3 files changed,
36 insertions(+),
0 deletions(-)
M
src/hex.c
→
src/hex.c
@@ -674,6 +674,11 @@ {
return 1; } int result = HEX_PUSH(ctx, item); + if (result == 0 && ctx->settings && ctx->settings->debugging_enabled) + { + // Validate the just-pushed quotation structure specifically + hex_validate_quotation_integrity(ctx, item); + } return result; }@@ -709,6 +714,11 @@ ctx->stack->entries[ctx->stack->top] = NULL; // Clear the stack reference
ctx->stack->top--; hex_debug_item(ctx, " POP", item); + if (ctx->settings && ctx->settings->debugging_enabled) + { + // Validate remaining stack after pop (helps catch corruption on removal) + hex_debug_validate_stack(ctx); + } return item; }@@ -4152,6 +4162,10 @@ HEX_FREE(ctx, item);
return 1; } int result = hex_push_string(ctx, hex_type(item->type)); + if (result == 0 && ctx->settings && ctx->settings->debugging_enabled) + { + hex_debug_validate_stack(ctx); + } HEX_FREE(ctx, item); return result; }@@ -4184,6 +4198,10 @@ hex_free_item(ctx, copy);
} HEX_FREE(ctx, item); return 1; + } + if (ctx->settings && ctx->settings->debugging_enabled) + { + hex_debug_validate_stack(ctx); } } HEX_FREE(ctx, item); // free original quotation (no aliasing remains)
M
src/stack.c
→
src/stack.c
@@ -233,6 +233,11 @@ {
return 1; } int result = HEX_PUSH(ctx, item); + if (result == 0 && ctx->settings && ctx->settings->debugging_enabled) + { + // Validate the just-pushed quotation structure specifically + hex_validate_quotation_integrity(ctx, item); + } return result; }@@ -268,6 +273,11 @@ ctx->stack->entries[ctx->stack->top] = NULL; // Clear the stack reference
ctx->stack->top--; hex_debug_item(ctx, " POP", item); + if (ctx->settings && ctx->settings->debugging_enabled) + { + // Validate remaining stack after pop (helps catch corruption on removal) + hex_debug_validate_stack(ctx); + } return item; }
M
src/symbols.c
→
src/symbols.c
@@ -206,6 +206,10 @@ HEX_FREE(ctx, item);
return 1; } int result = hex_push_string(ctx, hex_type(item->type)); + if (result == 0 && ctx->settings && ctx->settings->debugging_enabled) + { + hex_debug_validate_stack(ctx); + } HEX_FREE(ctx, item); return result; }@@ -238,6 +242,10 @@ hex_free_item(ctx, copy);
} HEX_FREE(ctx, item); return 1; + } + if (ctx->settings && ctx->settings->debugging_enabled) + { + hex_debug_validate_stack(ctx); } } HEX_FREE(ctx, item); // free original quotation (no aliasing remains)