Fix memory leak from ZCC_OpInfo operator prototypes

This commit is contained in:
Randy Heit 2016-03-03 20:26:13 -06:00
parent 5c1ec2c0bf
commit e4a74f4bbe
2 changed files with 23 additions and 0 deletions

View File

@ -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);

View File

@ -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