mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
pg: use unsafe
This commit is contained in:
parent
394d64bfd0
commit
c72e505fe4
@ -121,15 +121,18 @@ pub fn (db DB) exec_one(query string) ?pg.Row {
|
||||
return row
|
||||
}
|
||||
|
||||
//
|
||||
// The entire function can be considered unsafe because of the malloc and the
|
||||
// free. This prevents warnings and doesn't seem to affect behavior.
|
||||
pub fn (db DB) exec_param_many(query string, params []string) []pg.Row {
|
||||
unsafe {
|
||||
mut param_vals := &byteptr( malloc( params.len * sizeof(byteptr) ) )
|
||||
for i in 0..params.len {
|
||||
param_vals[i] = params[i].str
|
||||
}
|
||||
res := C.PQexecParams(db.conn, query.str, params.len, 0, param_vals, 0, 0, 0)
|
||||
unsafe{ free(param_vals) }
|
||||
free(param_vals)
|
||||
return db.handle_error_or_result(res, 'exec_param_many')
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (db DB) exec_param2(query string, param, param2 string) []pg.Row {
|
||||
|
Loading…
Reference in New Issue
Block a user