Skip to content

Commit 498016c

Browse files
committed
Added sqlite3_finalize() wrapper.
1 parent 96ab932 commit 498016c

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ application against `libfortran-sqlite3.a` and `-lsqlite3`.
2323
Simply execute the Fortran Package Manager:
2424

2525
```
26-
$ fpm build --profile release
26+
$ fpm build --profile=release
2727
```
2828

2929
The output files are written to `build/`.

src/sqlite.f90

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ module sqlite
169169
public :: sqlite3_exec
170170
public :: sqlite3_exec_
171171
public :: sqlite3_finalize
172+
public :: sqlite3_finalize_
172173
public :: sqlite3_free
173174
public :: sqlite3_initialize
174175
public :: sqlite3_last_insert_rowid
@@ -398,12 +399,12 @@ function sqlite3_exec_(db, sql, callback, client_data, errmsg) bind(c, name='sql
398399
end function sqlite3_exec_
399400

400401
! int sqlite3_finalize(sqlite3_stmt *stmt)
401-
function sqlite3_finalize(stmt) bind(c, name='sqlite3_finalize')
402+
function sqlite3_finalize_(stmt) bind(c, name='sqlite3_finalize')
402403
import :: c_int, c_ptr
403404
implicit none
404405
type(c_ptr), intent(in), value :: stmt
405-
integer(kind=c_int) :: sqlite3_finalize
406-
end function sqlite3_finalize
406+
integer(kind=c_int) :: sqlite3_finalize_
407+
end function sqlite3_finalize_
407408

408409
! int sqlite3_initialize(void)
409410
function sqlite3_initialize() bind(c, name='sqlite3_initialize')
@@ -723,6 +724,14 @@ function sqlite3_exec(db, sql, callback, client_data, errmsg)
723724
if (present(errmsg)) call c_f_str_ptr(ptr, errmsg)
724725
end function sqlite3_exec
725726

727+
function sqlite3_finalize(stmt)
728+
type(c_ptr), intent(inout) :: stmt
729+
integer :: sqlite3_finalize
730+
731+
sqlite3_finalize = sqlite3_finalize_(stmt)
732+
if (sqlite3_finalize == SQLITE_OK) stmt = c_null_ptr
733+
end function sqlite3_finalize
734+
726735
function sqlite3_libversion()
727736
type(c_ptr) :: ptr
728737
character(len=:), allocatable :: sqlite3_libversion

0 commit comments

Comments
 (0)