summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authoryuzu-eva <stevenhu@web.de>2024-11-20 19:23:57 +0100
committeryuzu-eva <stevenhu@web.de>2024-11-20 19:23:57 +0100
commitb411238e832803b037206ddc3355e6795a7ac659 (patch)
tree0377196a446f644681d52b9ba1144d431791fe56 /main.c
parentf9b0e18ccd4c0dc978887b5b2fb8eeb54b814393 (diff)
fixed error
Diffstat (limited to 'main.c')
-rw-r--r--main.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/main.c b/main.c
index 2b46ea1..129aa04 100644
--- a/main.c
+++ b/main.c
@@ -76,15 +76,14 @@ void print_matches(const char *sel)
while (fgets(line, sizeof(line), fp)) {
char *tmp = strdup(line);
char *name = getfield(tmp, 1);
- free(tmp);
tmp = strdup(line);
char *episode = getfield(tmp, 2);
- free(tmp);
if (strcasestr(name, sel) != NULL) {
printf("Name: %s Episode: %s", name, episode);
entry_found = 1;
}
+ free(tmp);
}
if (!entry_found) {
printf("Entry not found\n");
@@ -106,15 +105,14 @@ void print_single_match(const char *sel)
while (fgets(line, sizeof(line), fp)) {
char *tmp = strdup(line);
char *name = getfield(tmp, 1);
- free(tmp);
tmp = strdup(line);
char *episode = getfield(tmp, 2);
- free(tmp);
if (strncasecmp(name, sel, strlen(sel)) == 0) {
printf("Name: %s Episode: %s", name, episode);
entry_found = 1;
}
+ free(tmp);
}
if (!entry_found) {
printf("Entry not found\n");
@@ -168,10 +166,8 @@ void edit_entry(const entry_t *entry)
while (fgets(line, sizeof(line), fp_old)) {
char *tmp = strdup(line);
char *old_name = getfield(tmp, 1);
- free(tmp);
tmp = strdup(line);
char *old_ep = getfield(tmp, 2);
- free(tmp);
if (strncasecmp(old_name, entry->name, strlen(entry->name)) == 0) {
fprintf(fp_new, "%s,%s\n", old_name, entry->episode);
@@ -179,6 +175,7 @@ void edit_entry(const entry_t *entry)
} else {
fprintf(fp_new, "%s,%s", old_name, old_ep);
}
+ free(tmp);
}
if (!entry_found) {
printf("Entry not found\n");