aboutsummaryrefslogtreecommitdiff
path: root/src/helper_functions.c
diff options
context:
space:
mode:
authoriceyrazor <iceyrazor@mailfence.com>2026-03-06 22:34:50 -0600
committericeyrazor <iceyrazor@mailfence.com>2026-03-06 22:34:50 -0600
commitf3d03e71ede8e94e7137777ab5ad5570c3d11b31 (patch)
treeddd17a5e3e1c40e645772cb9466169b98389985d /src/helper_functions.c
parent5964950ca5c018e1163fe308fa4bb17b9220b383 (diff)
some cleanup and shell var
- SHELL is now set - cwd now has realloc - realloc with error checking is now a fucntion like malloce
Diffstat (limited to 'src/helper_functions.c')
-rw-r--r--src/helper_functions.c11
1 files changed, 10 insertions, 1 deletions
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);