mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
string: make substr() copy the data, like in Java and C#; remove .cstr()
this makes managing memory used by strings much easier V strings are now fully compatible with C strings
This commit is contained in:
@@ -29,7 +29,7 @@ fn C.PQgetvalue(voidptr, int, int) byteptr
|
||||
|
||||
pub fn connect(dbname, user string) DB {
|
||||
conninfo := 'host=localhost user=$user dbname=$dbname'
|
||||
conn:=C.PQconnectdb(conninfo.cstr())
|
||||
conn:=C.PQconnectdb(conninfo.str)
|
||||
status := C.PQstatus(conn)
|
||||
if status != CONNECTION_OK {
|
||||
error_msg := C.PQerrorMessage(conn)
|
||||
@@ -87,7 +87,7 @@ pub fn (db DB) q_strings(query string) []pg.Row {
|
||||
}
|
||||
|
||||
pub fn (db DB) exec(query string) []pg.Row {
|
||||
res := C.PQexec(db.conn, query.cstr())
|
||||
res := C.PQexec(db.conn, query.str)
|
||||
e := string(C.PQerrorMessage(db.conn))
|
||||
if e != '' {
|
||||
println('pg exec error:')
|
||||
|
Reference in New Issue
Block a user