mirror of
https://github.com/intel/llvm.git
synced 2026-01-14 20:10:50 +08:00
Free the memory allocated by mlirOperationStateAddXXX methods in mlirOperationCreate.
Previously, the memory leaks on heap. Since the MlirOperationState is not intended to be used again after mlirOperationCreate, the patch simplify frees the memory in mlirOperationCreate instead of creating any new API. Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D85629
This commit is contained in:
@@ -176,6 +176,12 @@ MlirOperation mlirOperationCreate(const MlirOperationState *state) {
|
||||
for (unsigned i = 0; i < state->nRegions; ++i)
|
||||
cppState.addRegion(std::unique_ptr<Region>(unwrap(state->regions[i])));
|
||||
|
||||
free(state->results);
|
||||
free(state->operands);
|
||||
free(state->regions);
|
||||
free(state->successors);
|
||||
free(state->attributes);
|
||||
|
||||
return wrap(Operation::create(cppState));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user