Skip to content

Commit

Permalink
Fixed de-allocate error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
smyrgeorge committed Jul 4, 2024
1 parent ce822c7 commit 763fb74
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,30 +185,30 @@ leaks -atExit -- ./examples/build/bin/macosArm64/releaseExecutable/examples.kexe
Sample output:

```text
Process: sqlx4k [36668]
Path: /Users/USER/*/sqlx4k.kexe
Load Address: 0x10011c000
Identifier: sqlx4k
Process: examples.kexe [47305]
Path: /Users/USER/*/examples.kexe
Load Address: 0x102968000
Identifier: examples.kexe
Version: 0
Code Type: ARM64
Platform: macOS
Parent Process: leaks [36667]
Parent Process: leaks [47304]
Date/Time: 2024-06-24 03:40:42.054 +0200
Launch Time: 2024-06-24 03:39:33.576 +0200
Date/Time: 2024-07-05 00:01:28.058 +0200
Launch Time: 2024-07-05 00:01:09.909 +0200
OS Version: macOS 14.5 (23F79)
Report Version: 7
Analysis Tool: /Applications/Xcode.app/Contents/Developer/usr/bin/leaks
Analysis Tool Version: Xcode 15.4 (15F31d)
Physical footprint: 18.5M
Physical footprint (peak): 19.8M
Physical footprint: 300.5M
Physical footprint (peak): 300.5M
Idle exit: untracked
----
leaks Report Version: 4.0, multi-line stacks
Process 36668: 1617 nodes malloced for 718 KB
Process 36668: 0 leaks for 0 total leaked bytes.
Process 47305: 188498 nodes malloced for 18565 KB
Process 47305: 0 leaks for 0 total leaked bytes.
```

## References
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group = "io.github.smyrgeorge"
version = "0.3.1"
version = "0.3.2"

plugins {
// https://plugins.gradle.org/plugin/org.jetbrains.kotlin.multiplatform
Expand Down
2 changes: 1 addition & 1 deletion examples/src/nativeMain/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fun main() {
// Map the value here.
"MAPPED_VALUE"
}.getOrThrow()
val error: Sqlx4k.Error = pg.query("select * from sqlx4kk").errorOrNull()
val error = pg.query("select * from sqlx4kk").errorOrNull()
println(error)

pg.query("create table if not exists sqlx4k(id integer);").getOrThrow()
Expand Down
2 changes: 1 addition & 1 deletion sqlx4k/rust_lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ pub extern "C" fn sqlx4k_tx_fetch_all(
pub extern "C" fn sqlx4k_free_result(ptr: *mut Sqlx4kResult) {
let ptr: Sqlx4kResult = unsafe { *Box::from_raw(ptr) };

if ptr.error > 0 {
if ptr.error >= 0 {
let error_message = unsafe { CString::from_raw(ptr.error_message) };
std::mem::drop(error_message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ internal suspend inline fun sqlx(crossinline f: (idx: ULong) -> Unit): CPointer<
}


fun Result<*>.errorOrNull(): Sqlx4k.Error =
exceptionOrNull() as Sqlx4k.Error
fun Result<*>.errorOrNull(): Sqlx4k.Error? =
exceptionOrNull() as? Sqlx4k.Error

0 comments on commit 763fb74

Please sign in to comment.