From 5e2b718c15087ee3401a6c0e1d80196e92f2aa06 Mon Sep 17 00:00:00 2001 From: Niklas Halle Date: Thu, 21 May 2020 12:32:30 +0200 Subject: re-added error handling --- 02_exercise/shell.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/02_exercise/shell.c b/02_exercise/shell.c index c960680..1c03961 100644 --- a/02_exercise/shell.c +++ b/02_exercise/shell.c @@ -65,12 +65,10 @@ int parse_line(char const *line, char ***parts, size_t *part_count) { char *part; char **local_parts; - arrayInit(part); - arrayInit(local_parts); -/* if (arrayInit(part) != 0 || arrayInit(local_parts) != 0) { - fprintf(stderr, "Failed to prepare new part array"); - exit(-1); - }*/ + if (arrayInit(part) != 0 || arrayInit(local_parts) != 0) { + fprintf(stderr, "Failed to prepare new part / parts array whilst parsing line"); + return -1; + } char c; int i = 0; @@ -97,8 +95,8 @@ int parse_line(char const *line, char ***parts, size_t *part_count) { } void print_prompt() { - size_t length = 1024; - char *buffer = malloc(length * sizeof(char)); + size_t length = 1024; + char *buffer = malloc(length * sizeof(char)); getcwd(buffer, length); if (buffer == NULL) { printf(".> "); -- cgit v1.2.3-54-g00ecf