From 7c84497926bf7e7c709534699e39751c2a333a3b Mon Sep 17 00:00:00 2001 From: Gideon Bature Date: Wed, 26 Jul 2023 03:02:16 +0100 Subject: [PATCH] fix whole code for full compilation --- linkedlist.c | 9 ++++----- main.c | 9 ++++++--- shell | Bin 22144 -> 22144 bytes 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/linkedlist.c b/linkedlist.c index 0778e6c..5d560d6 100644 --- a/linkedlist.c +++ b/linkedlist.c @@ -2,6 +2,7 @@ envstruct *insert_end(envstruct *head, char *key, char *value) { + envstruct *curr = head; envstruct *new_node = malloc(sizeof(envstruct)); if (new_node == NULL) @@ -18,8 +19,6 @@ envstruct *insert_end(envstruct *head, char *key, char *value) return (new_node); } - envstruct *curr; - curr = head; while (curr->next != NULL) { @@ -67,14 +66,14 @@ char *get_value(envstruct *head, char *key) */ int remove_value(envstruct **head, char *key) { + envstruct *curr = *head; + envstruct *prev = NULL; + if (head == NULL || *head == NULL) { return (1); } - envstruct *curr = *head; - envstruct *prev = NULL; - while (curr != NULL) { if (strcmp(curr->key, key) == 0) diff --git a/main.c b/main.c index 2f7a06c..010eae7 100644 --- a/main.c +++ b/main.c @@ -10,9 +10,10 @@ char *lineptr; */ int main(void) { + envstruct *head = NULL; + atexit(clean_up); signal(SIGINT, sig_int_handler); - envstruct *head = NULL; while (1) { @@ -235,7 +236,9 @@ void env_cmd(void) */ void init_env_list(envstruct *head) { - while (*environ != NULL) + int i = 0; + + while (environ[i] != NULL) { char *key = strtok(*environ, "="), *val = NULL; @@ -246,7 +249,7 @@ void init_env_list(envstruct *head) } head = insert_end(head, key, val); - *environ++; + i++; } } diff --git a/shell b/shell index 98ade317161ae03fc8fdf8ea893ce8f5236d9da1..eb43a924a9b3db1395ef9c9d2910311699afe937 100755 GIT binary patch delta 2493 zcmZ8ieNa?Y6n_uc6k1q9z7}>_KtrVoTr|+ivhc~%vX2=lZE75ow5F_ahE+=m#*Jon z9xKSPMn`LMG98<&CY>TvK`maEAB;7M=^u;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