From 070c57daec076e780e81d8b1011a02ea8ac8915f Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 4 Apr 2017 21:53:44 +0300 Subject: fixes for memory leak for user-supplied sorting function. --- awk.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'awk.h') diff --git a/awk.h b/awk.h index c1e9b4a9..6b7cdb7a 100644 --- a/awk.h +++ b/awk.h @@ -783,6 +783,7 @@ typedef struct exp_instruction { } x; short source_line; + short pool_size; // memory management in symbol.c OPCODE opcode; } INSTRUCTION; @@ -1031,9 +1032,15 @@ typedef struct srcfile { int lasttok; } SRCFILE; +// structure for INSTRUCTION pool, needed mainly for debugger +typedef struct instruction_pool { +#define MAX_INSTRUCTION_ALLOC 3 // we don't call bcalloc with more than this + INSTRUCTION pool[MAX_INSTRUCTION_ALLOC + 1]; +} INSTRUCTION_POOL; + /* structure for execution context */ typedef struct context { - INSTRUCTION pools; + INSTRUCTION_POOL pools; NODE symbols; INSTRUCTION rule_list; SRCFILE srcfiles; -- cgit v1.2.3 From 22bfbd1057c2fa9d5e5b2401d6b1ab60737452d9 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Fri, 7 Apr 2017 11:30:22 -0400 Subject: Patch INSTRUCTION allocator to malloc instruction blocks and eliminate leaks. --- awk.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'awk.h') diff --git a/awk.h b/awk.h index 6b7cdb7a..c7bfec2b 100644 --- a/awk.h +++ b/awk.h @@ -1035,7 +1035,11 @@ typedef struct srcfile { // structure for INSTRUCTION pool, needed mainly for debugger typedef struct instruction_pool { #define MAX_INSTRUCTION_ALLOC 3 // we don't call bcalloc with more than this - INSTRUCTION pool[MAX_INSTRUCTION_ALLOC + 1]; + struct instruction_mem_pool { + struct instruction_block *block_list; + INSTRUCTION *free_space; // free location in active block + INSTRUCTION *free_list; + } pool[MAX_INSTRUCTION_ALLOC]; } INSTRUCTION_POOL; /* structure for execution context */ -- cgit v1.2.3 From 887477763ab87b33c06df693e93500991d7c324d Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Mon, 10 Apr 2017 12:04:25 -0400 Subject: Use Op_illegal instead of 0 in a couple of places for greater clarity. --- awk.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'awk.h') diff --git a/awk.h b/awk.h index c7bfec2b..5cad2044 100644 --- a/awk.h +++ b/awk.h @@ -597,8 +597,7 @@ typedef enum lintvals { /* --------------------------------Instruction ---------------------------------- */ typedef enum opcodeval { - /* illegal entry == 0 */ - Op_illegal, + Op_illegal = 0, /* illegal entry */ /* binary operators */ Op_times, -- cgit v1.2.3