aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorTristan Riehs <tristan.riehs@inria.fr>2025-11-16 10:34:42 +0100
committerTristan Riehs <tristan.riehs@inria.fr>2025-11-16 10:40:07 +0100
commit3c51013fd46ad10b381038932d282cc2bc45df72 (patch)
tree01faafaef049d78a33bb42b49b59ca5445097600 /src/main.c
parent85b3cf1a9e26c98366c6b0b11316447f9afddf3e (diff)
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.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c9
1 files 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);
}