From 3c51013fd46ad10b381038932d282cc2bc45df72 Mon Sep 17 00:00:00 2001 From: Tristan Riehs Date: Sun, 16 Nov 2025 10:34:42 +0100 Subject: Change id management in ftag_file_add There is no need to pass a pointer to the ID to ftag_add_one_file, the ID itself is enough. --- src/main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 0472920..a2ecb4e 100644 --- a/src/main.c +++ b/src/main.c @@ -160,7 +160,7 @@ static void canonicalize(char *out, const char *in) /* Add a new file to the databse, prompting the user for needed information. */ static void ftag_add_one_file(sqlite3 *db, - int *next_id, + int next_id, const char *file) { char sql[2048]; @@ -244,7 +244,6 @@ static void ftag_add_one_file(sqlite3 *db, *next_id, canonical_name, full_name, description, date); rc = sqlite3_exec(db, sql, NULL, NULL, NULL); sqlite3_check(rc, db); - (*next_id)++; char new_path[512]; memset(new_path, 0, sizeof(new_path)); @@ -292,8 +291,10 @@ static void ftag_file_add(int argc, char **argv) rc = sqlite3_open(DATABASE_PATH, &db); sqlite3_check(rc, db); int next_id = table_next_id(db, "files"); - for (int i = 0; i < argc; i++) - ftag_add_one_file(db, &next_id, argv[i]); + for (int i = 0; i < argc; i++) { + ftag_add_one_file(db, next_id, argv[i]); + next_id++; + } sqlite3_close(db); } -- cgit v1.2.3