Resolve leaks moving from Add to Sink

This commit is contained in:
ReinUsesLisp 2018-10-23 05:02:18 -03:00
parent 951ef21f17
commit f581df0935
3 changed files with 11 additions and 11 deletions

View file

@ -14,7 +14,7 @@ Ref Module::Decorate(Ref target, spv::Decoration decoration,
auto const op{new Op(spv::Op::OpDecorate)};
op->Add(target);
AddEnum(op, decoration);
op->Add(literals);
op->Sink(literals);
return AddAnnotation(op);
}

View file

@ -65,11 +65,17 @@ void Op::Sink(Operand* operand) {
operand_store.push_back(std::unique_ptr<Operand>(operand));
}
void Op::Sink(const std::vector<Operand*>& operands) {
for (Operand* operand : operands) {
Sink(operand);
}
}
void Op::Add(const Operand* operand) { operands.push_back(operand); }
void Op::Add(u32 integer) { Add(LiteralNumber::Create<u32>(integer)); }
void Op::Add(u32 integer) { Sink(LiteralNumber::Create<u32>(integer)); }
void Op::Add(const std::string& string) { Add(new LiteralString(string)); }
void Op::Add(const std::string& string) { Sink(new LiteralString(string)); }
void Op::Add(const std::vector<Ref>& ids) {
for (Ref op : ids) {
@ -77,12 +83,6 @@ void Op::Add(const std::vector<Ref>& ids) {
}
}
void Op::Add(const std::vector<Operand*>& operands) {
for (Operand* operand : operands) {
Add(operand);
}
}
u16 Op::WordCount() const {
u16 count{1};
if (result_type) {

View file

@ -29,6 +29,8 @@ class Op : public Operand {
void Sink(Operand* operand);
void Sink(const std::vector<Operand*>& operands);
void Add(const Operand* operand);
void Add(u32 integer);
@ -37,8 +39,6 @@ class Op : public Operand {
void Add(const std::vector<Ref>& ids);
void Add(const std::vector<Operand*>& operands);
private:
u16 WordCount() const;