mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 00:08:30 +00:00
Update SQLite deserialize to allow resizing restored DB (#701)
Using either option (FREEONCLOSE or RESIZEABLE) requires using sqlite3_malloc. Ref. #436
This commit is contained in:
parent
b850b14300
commit
bcae817215
2 changed files with 9 additions and 3 deletions
|
@ -1812,8 +1812,9 @@ static int db_deserialize(lua_State *L) {
|
|||
if (buffer == NULL || size == 0) /* ignore empty database content */
|
||||
return 0;
|
||||
|
||||
sqlite3_deserialize(db->db, "main", buffer, size, size, 0);
|
||||
free(buffer);
|
||||
const char *sqlbuf = memcpy(sqlite3_malloc(size), buffer, size);
|
||||
sqlite3_deserialize(db->db, "main", sqlbuf, size, size,
|
||||
SQLITE_DESERIALIZE_FREEONCLOSE + SQLITE_DESERIALIZE_RESIZEABLE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue