mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 22:45:59 +01:00
Use g_strlcat
It has a sane API. Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
parent
43244a67d2
commit
599e61ccf1
1 changed files with 11 additions and 16 deletions
|
@ -251,24 +251,19 @@ sqlite_db_init(ZathuraSQLDatabase* db, const char* path)
|
||||||
girara_debug("old database table layout detected; updating ...");
|
girara_debug("old database table layout detected; updating ...");
|
||||||
|
|
||||||
/* prepare transaction */
|
/* prepare transaction */
|
||||||
char tx_begin[] = "BEGIN TRANSACTION;"
|
static const char tx_begin[] =
|
||||||
"ALTER TABLE fileinfo RENAME TO tmp;";
|
"BEGIN TRANSACTION;"
|
||||||
char tx_end[] = "INSERT INTO fileinfo SELECT * FROM tmp;"
|
"ALTER TABLE fileinfo RENAME TO tmp;";
|
||||||
"DROP TABLE tmp;"
|
static const char tx_end[] =
|
||||||
"COMMIT;";
|
"INSERT INTO fileinfo SELECT * FROM tmp;"
|
||||||
|
"DROP TABLE tmp;"
|
||||||
/* calculate requred buffer size */
|
"COMMIT;";
|
||||||
size_t tx_buffer_size = strlen(tx_begin);
|
|
||||||
tx_buffer_size += strlen(SQL_FILEINFO_INIT);
|
|
||||||
tx_buffer_size += strlen(tx_end);
|
|
||||||
++tx_buffer_size;
|
|
||||||
|
|
||||||
/* assemble transaction */
|
/* assemble transaction */
|
||||||
char transaction[tx_buffer_size];
|
char transaction[sizeof(tx_begin) + sizeof(SQL_FILEINFO_INIT) + sizeof(tx_end) - 2] = { '\0' };
|
||||||
bzero(transaction, tx_buffer_size);
|
g_strlcat(transaction, tx_begin, sizeof(transaction));
|
||||||
strcat(transaction, tx_begin);
|
g_strlcat(transaction, SQL_FILEINFO_INIT, sizeof(transaction));
|
||||||
strcat(transaction, SQL_FILEINFO_INIT);
|
g_strlcat(transaction, tx_end, sizeof(transaction));
|
||||||
strcat(transaction, tx_end);
|
|
||||||
|
|
||||||
if (sqlite3_exec(session, transaction, NULL, 0, NULL) != SQLITE_OK) {
|
if (sqlite3_exec(session, transaction, NULL, 0, NULL) != SQLITE_OK) {
|
||||||
girara_warning("failed to update database table layout");
|
girara_warning("failed to update database table layout");
|
||||||
|
|
Loading…
Reference in a new issue