From f3d03e71ede8e94e7137777ab5ad5570c3d11b31 Mon Sep 17 00:00:00 2001 From: iceyrazor Date: Fri, 6 Mar 2026 22:34:50 -0600 Subject: some cleanup and shell var - SHELL is now set - cwd now has realloc - realloc with error checking is now a fucntion like malloce --- src/helper_functions.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/helper_functions.c') diff --git a/src/helper_functions.c b/src/helper_functions.c index 162cf45..cd35848 100644 --- a/src/helper_functions.c +++ b/src/helper_functions.c @@ -16,6 +16,15 @@ void *malloce(size_t size){ return mal; } +void *realloce(void* mal,size_t size){ + mal=realloc(mal,size); + if(!mal){ + fprintf(stderr, "lsh: allocation error\n"); + exit(EXIT_FAILURE); + } + return mal; +} + char *pop(char *token, int ch_i){ if(token[ch_i]=='\0'){ return token; @@ -83,7 +92,7 @@ char *basename(char *path_in) { char *token = NULL; char *lastToken = NULL; - char *basePath; + char *basePath = NULL; basePath = (char *)malloce(sizeof(char) * (strlen(path_in) + 1)); strcpy(basePath, path_in); -- cgit v1.3