From 464f4277cc1d6e6a01f1901e4a79ac7c4d13243b Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 7 Aug 2022 01:57:06 +0200 Subject: [PATCH] fixed a memory leak in (de)compress_string --- rulegen.cpp | 5 +++++ rulegen3.cpp | 5 +++-- util.cpp | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/rulegen.cpp b/rulegen.cpp index 735496a8..aa076967 100644 --- a/rulegen.cpp +++ b/rulegen.cpp @@ -86,6 +86,11 @@ static const flagtype w_less_smart_retrace = Flag(22); /*< stop early when exami static const flagtype w_less_smart_advance = Flag(23); /*< stop early when examining smart shortcut advancement */ static const flagtype w_no_queued_extensions = Flag(24); /*< consider extensions one by one */ static const flagtype w_no_branch_skipping = Flag(24); /*< do not skip branches */ + +/* for 3D honeycombs */ +static const flagtype w_skip_transducers = Flag(32); /*< skip the transducer test */ +static const flagtype w_skip_transducer_loops = Flag(33); /*< skip loops during the transducer test */ +static const flagtype w_skip_transducer_terminate = Flag(34); /*< skip termination during the transducer test */ #endif EX int honeycomb_value = 1; /* how far to build local for honeycombs */ diff --git a/rulegen3.cpp b/rulegen3.cpp index 57e92332..2cea813e 100644 --- a/rulegen3.cpp +++ b/rulegen3.cpp @@ -1028,6 +1028,7 @@ EX void find_multiple_interpretation() { } EX void test_transducers() { + if(flags & w_skip_transducers) return; autom.clear(); int iterations = 0; while(true) { @@ -1159,7 +1160,7 @@ EX void test_transducers() { extract(autom, special[tid][dir], tid, dir); } - for(int tid=0; tid, vector< pair> > by_roadsign; diff --git a/util.cpp b/util.cpp index 6cd0858f..822c9267 100644 --- a/util.cpp +++ b/util.cpp @@ -737,6 +737,7 @@ EX string compress_string(string s) { if(deflate(&strm, Z_FINISH) != Z_STREAM_END) throw hr_exception("z-error-2"); println(hlog, "deflate ok"); string out(&buf[0], (char*)(strm.next_out) - &buf[0]); + deflateEnd(&strm); println(hlog, isize(s), " -> ", isize(out)); return out; } @@ -753,8 +754,9 @@ EX string decompress_string(string s) { vector buf(10000000, 0); strm.avail_out = 10000000; strm.next_out = (Bytef*) &buf[0]; - if(inflate(&strm, Z_FINISH) != Z_STREAM_END) throw hr_exception("z-error-2"); + if(inflate(&strm, Z_FINISH) != Z_STREAM_END) throw hr_exception("z-error-2"); string out(&buf[0], (char*)(strm.next_out) - &buf[0]); + inflateEnd(&strm); println(hlog, isize(s), " -> ", isize(out)); return out; }