This commit is contained in:
Your Name 2025-06-01 22:10:12 +03:00
parent 88cc0d9240
commit 87df230ecb

17
img.c
View file

@ -128,13 +128,8 @@ void add(char **list, const int size, const char *desc) {
} }
void free_db(struct DB_STR *db) { void free_db(struct DB_STR *db) {
if (db == NULL)
return;
while (db != NULL) { while (db != NULL) {
struct DB_STR *i = db->next; struct DB_STR *i = db->next;
if (i == NULL)
return;
if (db->filename != NULL) if (db->filename != NULL)
free(db->filename); free(db->filename);
@ -194,11 +189,11 @@ struct DB_STR *new_db_value(char *str) {
if (tok != NULL) { if (tok != NULL) {
db->filename = strdup(tok); db->filename = strdup(tok);
if (db->filename == NULL) if (db->filename == NULL)
goto NDV_CLOSE; goto NEW_DB_VALUE_CLOSE;
} }
else else
goto NDV_CLOSE; goto NEW_DB_VALUE_CLOSE;
/* Tags */ /* Tags */
tok = strtok_r(tok_rest, "|", &tok_rest); tok = strtok_r(tok_rest, "|", &tok_rest);
@ -214,7 +209,7 @@ struct DB_STR *new_db_value(char *str) {
char *tok2; char *tok2;
while ((tok2 = strtok_r(tok2_rest, ",", &tok2_rest)) != NULL) { while ((tok2 = strtok_r(tok2_rest, ",", &tok2_rest)) != NULL) {
if (append_tag(db, tok2, allocated)) if (append_tag(db, tok2, allocated))
goto NDV_CLOSE; goto NEW_DB_VALUE_CLOSE;
allocated++; allocated++;
} }
@ -236,7 +231,7 @@ struct DB_STR *new_db_value(char *str) {
db->birthtime = sb.st_mtime; db->birthtime = sb.st_mtime;
return db; return db;
NDV_CLOSE: NEW_DB_VALUE_CLOSE:
free_db(db); free_db(db);
return NULL; return NULL;
} }
@ -264,7 +259,7 @@ struct DB_STR *read_db(void) {
db = new_db_value(line); db = new_db_value(line);
if (db == NULL) if (db == NULL)
goto RDB_CLOSE; goto READ_DB_CLOSE;
db->next = i; db->next = i;
i = db; i = db;
@ -272,7 +267,7 @@ struct DB_STR *read_db(void) {
ret = 0; ret = 0;
RDB_CLOSE: READ_DB_CLOSE:
fclose(fp); fclose(fp);
if (line) if (line)
free(line); free(line);