fixed
This commit is contained in:
parent
88cc0d9240
commit
87df230ecb
1 changed files with 6 additions and 11 deletions
17
img.c
17
img.c
|
@ -128,13 +128,8 @@ void add(char **list, const int size, const char *desc) {
|
|||
}
|
||||
|
||||
void free_db(struct DB_STR *db) {
|
||||
if (db == NULL)
|
||||
return;
|
||||
|
||||
while (db != NULL) {
|
||||
struct DB_STR *i = db->next;
|
||||
if (i == NULL)
|
||||
return;
|
||||
|
||||
if (db->filename != NULL)
|
||||
free(db->filename);
|
||||
|
@ -194,11 +189,11 @@ struct DB_STR *new_db_value(char *str) {
|
|||
if (tok != NULL) {
|
||||
db->filename = strdup(tok);
|
||||
if (db->filename == NULL)
|
||||
goto NDV_CLOSE;
|
||||
goto NEW_DB_VALUE_CLOSE;
|
||||
}
|
||||
|
||||
else
|
||||
goto NDV_CLOSE;
|
||||
goto NEW_DB_VALUE_CLOSE;
|
||||
|
||||
/* Tags */
|
||||
tok = strtok_r(tok_rest, "|", &tok_rest);
|
||||
|
@ -214,7 +209,7 @@ struct DB_STR *new_db_value(char *str) {
|
|||
char *tok2;
|
||||
while ((tok2 = strtok_r(tok2_rest, ",", &tok2_rest)) != NULL) {
|
||||
if (append_tag(db, tok2, allocated))
|
||||
goto NDV_CLOSE;
|
||||
goto NEW_DB_VALUE_CLOSE;
|
||||
|
||||
allocated++;
|
||||
}
|
||||
|
@ -236,7 +231,7 @@ struct DB_STR *new_db_value(char *str) {
|
|||
db->birthtime = sb.st_mtime;
|
||||
return db;
|
||||
|
||||
NDV_CLOSE:
|
||||
NEW_DB_VALUE_CLOSE:
|
||||
free_db(db);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -264,7 +259,7 @@ struct DB_STR *read_db(void) {
|
|||
|
||||
db = new_db_value(line);
|
||||
if (db == NULL)
|
||||
goto RDB_CLOSE;
|
||||
goto READ_DB_CLOSE;
|
||||
|
||||
db->next = i;
|
||||
i = db;
|
||||
|
@ -272,7 +267,7 @@ struct DB_STR *read_db(void) {
|
|||
|
||||
ret = 0;
|
||||
|
||||
RDB_CLOSE:
|
||||
READ_DB_CLOSE:
|
||||
fclose(fp);
|
||||
if (line)
|
||||
free(line);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue