diff --git a/src/zscript/zcc_expr.cpp b/src/zscript/zcc_expr.cpp index 69a25970b4..644a122a5a 100644 --- a/src/zscript/zcc_expr.cpp +++ b/src/zscript/zcc_expr.cpp @@ -33,6 +33,27 @@ struct OpProto2 EvalConst2op EvalConst; }; +static struct FreeOpInfoProtos +{ + ~FreeOpInfoProtos() + { + for (size_t i = 0; i < countof(ZCC_OpInfo); ++i) + { + ZCC_OpInfo[i].FreeAllProtos(); + } + } +} ProtoFreeer; + +void ZCC_OpInfoType::FreeAllProtos() +{ + for (ZCC_OpProto *proto = Protos, *next = NULL; proto != NULL; proto = next) + { + next = proto->Next; + delete proto; + } + Protos = NULL; +} + void ZCC_OpInfoType::AddProto(PType *res, PType *optype, EvalConst1op evalconst) { ZCC_OpProto *proto = new ZCC_OpProto(res, optype, NULL); diff --git a/src/zscript/zcc_parser.h b/src/zscript/zcc_parser.h index 1621aaa099..cf51ff7651 100644 --- a/src/zscript/zcc_parser.h +++ b/src/zscript/zcc_parser.h @@ -489,6 +489,8 @@ struct ZCC_OpInfoType ZCC_OpProto *FindBestProto(PType *optype, const PType::Conversion **route, int &numslots); ZCC_OpProto *FindBestProto(PType *left, const PType::Conversion **route1, int &numslots, PType *right, const PType::Conversion **route2, int &numslots2); + + void FreeAllProtos(); }; #define CONVERSION_ROUTE_SIZE 8