mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: disallow struct int to ptr outside unsafe (#17923)
This commit is contained in:
@ -126,7 +126,7 @@ fn C.sqlite3_changes(&C.sqlite3) int
|
||||
|
||||
// connect Opens the connection with a database.
|
||||
pub fn connect(path string) !DB {
|
||||
db := &C.sqlite3(0)
|
||||
db := &C.sqlite3(unsafe { nil })
|
||||
code := C.sqlite3_open(&char(path.str), &db)
|
||||
if code != 0 {
|
||||
return &SQLError{
|
||||
@ -181,7 +181,7 @@ pub fn (db &DB) get_affected_rows_count() int {
|
||||
|
||||
// Returns a single cell with value int.
|
||||
pub fn (db &DB) q_int(query string) int {
|
||||
stmt := &C.sqlite3_stmt(0)
|
||||
stmt := &C.sqlite3_stmt(unsafe { nil })
|
||||
defer {
|
||||
C.sqlite3_finalize(stmt)
|
||||
}
|
||||
@ -194,7 +194,7 @@ pub fn (db &DB) q_int(query string) int {
|
||||
|
||||
// Returns a single cell with value string.
|
||||
pub fn (db &DB) q_string(query string) string {
|
||||
stmt := &C.sqlite3_stmt(0)
|
||||
stmt := &C.sqlite3_stmt(unsafe { nil })
|
||||
defer {
|
||||
C.sqlite3_finalize(stmt)
|
||||
}
|
||||
@ -209,7 +209,7 @@ pub fn (db &DB) q_string(query string) string {
|
||||
// Result codes: https://www.sqlite.org/rescode.html
|
||||
[manualfree]
|
||||
pub fn (db &DB) exec(query string) ([]Row, int) {
|
||||
stmt := &C.sqlite3_stmt(0)
|
||||
stmt := &C.sqlite3_stmt(unsafe { nil })
|
||||
defer {
|
||||
C.sqlite3_finalize(stmt)
|
||||
}
|
||||
@ -276,7 +276,7 @@ pub fn (db &DB) error_message(code int, query string) IError {
|
||||
// In case you don't expect any row results, but still want a result code.
|
||||
// e.g. INSERT INTO ... VALUES (...)
|
||||
pub fn (db &DB) exec_none(query string) int {
|
||||
stmt := &C.sqlite3_stmt(0)
|
||||
stmt := &C.sqlite3_stmt(unsafe { nil })
|
||||
C.sqlite3_prepare_v2(db.conn, &char(query.str), query.len, &stmt, 0)
|
||||
code := C.sqlite3_step(stmt)
|
||||
C.sqlite3_finalize(stmt)
|
||||
|
@ -149,7 +149,7 @@ pub enum OpenModeFlag {
|
||||
// connect_full Opens connection to sqlite database. It gives more control than `open`.
|
||||
// Flags give control over readonly and create decisions. Specific VFS can be chosen.
|
||||
pub fn connect_full(path string, mode_flags []OpenModeFlag, vfs_name string) !DB {
|
||||
db := &C.sqlite3(0)
|
||||
db := &C.sqlite3(unsafe { nil })
|
||||
|
||||
mut flags := 0
|
||||
|
||||
|
Reference in New Issue
Block a user