Skip to content

Commit 49c3f6b

Browse files
authored
Merge pull request #58 from SpringQL/fix/SpringSourceRowBuiler-close
fix: free SpringSourceRowBuilder inside spring_source_row_build()
2 parents 2e2d55d + fbdc5da commit 49c3f6b

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ Also check the changes in springql-core: <https://github.com/SpringQL/SpringQL/b
1313
<!-- markdownlint-disable MD024 -->
1414
## [Unreleased]
1515

16+
## [v0.16.0+3] - 2022-07-11
17+
18+
### Fixed
19+
20+
- Memory leak of `SpringSourceRowBuilder` ([#58](https://github.com/SpringQL/SpringQL-client-c/pull/58))
21+
1622
## [v0.16.0+2] - 2022-07-06
1723

1824
### Added
@@ -118,8 +124,9 @@ Depends on springql-core v0.7.1.
118124
[Semantic Versioning]: https://semver.org/
119125

120126
<!-- Versions -->
121-
[Unreleased]: https://github.com/SpringQL/SpringQL-client-c/compare/v0.16.0+2...HEAD
127+
[Unreleased]: https://github.com/SpringQL/SpringQL-client-c/compare/v0.16.0+3...HEAD
122128
[Released]: https://github.com/SpringQL/SpringQL-client-c/releases
129+
[v0.16.0+3]: https://github.com/SpringQL/SpringQL-client-c/compare/v0.16.0+2...v0.16.0+3
123130
[v0.16.0+2]: https://github.com/SpringQL/SpringQL-client-c/compare/v0.16.0...v0.16.0+2
124131
[v0.16.0]: https://github.com/SpringQL/SpringQL-client-c/compare/v0.15.0+2...v0.16.0
125132
[v0.15.0+2]: https://github.com/SpringQL/SpringQL-client-c/compare/v0.15.0...v0.15.0+2

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

springql.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ enum SpringErrno spring_source_row_add_column_blob(SpringSourceRowBuilder *build
232232
/**
233233
* Finish creating a source row using a builder.
234234
*
235+
* The heap space for the `builder` is internally freed.
236+
*
235237
* # Returns
236238
*
237239
* SpringSourceRow

src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ pub unsafe extern "C" fn spring_source_row_add_column_blob(
305305
}
306306
/// Finish creating a source row using a builder.
307307
///
308+
/// The heap space for the `builder` is internally freed.
309+
///
308310
/// # Returns
309311
///
310312
/// SpringSourceRow
@@ -313,7 +315,9 @@ pub unsafe extern "C" fn spring_source_row_build(
313315
builder: *mut SpringSourceRowBuilder,
314316
) -> *mut SpringSourceRow {
315317
let rust_builder = (*builder).to_row_builder();
316-
SpringSourceRow::new(rust_builder.build()).into_ptr()
318+
let ret = SpringSourceRow::new(rust_builder.build()).into_ptr();
319+
SpringSourceRowBuilder::drop(builder);
320+
ret
317321
}
318322

319323
/// Frees heap occupied by a `SpringSourceRow`.

0 commit comments

Comments
 (0)