From a4ef64d7e2c8bf81081ee1a589e13c1e032c2fb1 Mon Sep 17 00:00:00 2001 From: Sho Nakatani Date: Mon, 11 Jul 2022 14:42:58 +0900 Subject: [PATCH 1/2] fix: free SpringSourceRowBuilder inside spring_source_row_build() --- Cargo.lock | 2 +- springql.h | 2 ++ src/lib.rs | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d744b06..ebc83a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1044,7 +1044,7 @@ dependencies = [ [[package]] name = "springql-client-c" -version = "0.16.0" +version = "0.16.0+2" dependencies = [ "cbindgen", "log", diff --git a/springql.h b/springql.h index 8762090..f35e43d 100644 --- a/springql.h +++ b/springql.h @@ -232,6 +232,8 @@ enum SpringErrno spring_source_row_add_column_blob(SpringSourceRowBuilder *build /** * Finish creating a source row using a builder. * + * The heap space for the `builder` is internally freed. + * * # Returns * * SpringSourceRow diff --git a/src/lib.rs b/src/lib.rs index e76f2d8..d708867 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -305,6 +305,8 @@ pub unsafe extern "C" fn spring_source_row_add_column_blob( } /// Finish creating a source row using a builder. /// +/// The heap space for the `builder` is internally freed. +/// /// # Returns /// /// SpringSourceRow @@ -313,7 +315,9 @@ pub unsafe extern "C" fn spring_source_row_build( builder: *mut SpringSourceRowBuilder, ) -> *mut SpringSourceRow { let rust_builder = (*builder).to_row_builder(); - SpringSourceRow::new(rust_builder.build()).into_ptr() + let ret = SpringSourceRow::new(rust_builder.build()).into_ptr(); + SpringSourceRowBuilder::drop(builder); + ret } /// Frees heap occupied by a `SpringSourceRow`. From fbdc5dab25d4046b98c9c1dadeb0dc2a2602bfc7 Mon Sep 17 00:00:00 2001 From: Sho Nakatani Date: Mon, 11 Jul 2022 14:49:03 +0900 Subject: [PATCH 2/2] docs: update CHANGELOG --- CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e5c8f6..4858888 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,12 @@ Also check the changes in springql-core: ## [Unreleased] +## [v0.16.0+3] - 2022-07-11 + +### Fixed + +- Memory leak of `SpringSourceRowBuilder` ([#58](https://github.com/SpringQL/SpringQL-client-c/pull/58)) + ## [v0.16.0+2] - 2022-07-06 ### Added @@ -118,8 +124,9 @@ Depends on springql-core v0.7.1. [Semantic Versioning]: https://semver.org/ -[Unreleased]: https://github.com/SpringQL/SpringQL-client-c/compare/v0.16.0+2...HEAD +[Unreleased]: https://github.com/SpringQL/SpringQL-client-c/compare/v0.16.0+3...HEAD [Released]: https://github.com/SpringQL/SpringQL-client-c/releases +[v0.16.0+3]: https://github.com/SpringQL/SpringQL-client-c/compare/v0.16.0+2...v0.16.0+3 [v0.16.0+2]: https://github.com/SpringQL/SpringQL-client-c/compare/v0.16.0...v0.16.0+2 [v0.16.0]: https://github.com/SpringQL/SpringQL-client-c/compare/v0.15.0+2...v0.16.0 [v0.15.0+2]: https://github.com/SpringQL/SpringQL-client-c/compare/v0.15.0...v0.15.0+2