diff options
| author | Jing Pu <jingpu@google.com> | 2020-08-10 10:32:24 +0200 |
|---|---|---|
| committer | Alex Zinenko <zinenko@google.com> | 2020-08-10 10:32:50 +0200 |
| commit | 69eb7e36aa3c71997811054bb31d4546b08bfff0 (patch) | |
| tree | 21f96b4a9b68b0a08cdc82373ec7882747d4b988 | |
| parent | 0d58d9e8fb937b422baaf96dc7c60e7c3a128302 (diff) | |
| download | llvm-69eb7e36aa3c71997811054bb31d4546b08bfff0.zip llvm-69eb7e36aa3c71997811054bb31d4546b08bfff0.tar.gz llvm-69eb7e36aa3c71997811054bb31d4546b08bfff0.tar.bz2 | |
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
| -rw-r--r-- | mlir/lib/CAPI/IR/IR.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/mlir/lib/CAPI/IR/IR.cpp b/mlir/lib/CAPI/IR/IR.cpp index 3161bda..be47732 100644 --- a/mlir/lib/CAPI/IR/IR.cpp +++ b/mlir/lib/CAPI/IR/IR.cpp @@ -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)); } |
