diff options
| author | iceyrazor <iceyrazor@mailfence.com> | 2026-03-06 22:34:50 -0600 |
|---|---|---|
| committer | iceyrazor <iceyrazor@mailfence.com> | 2026-03-06 22:34:50 -0600 |
| commit | f3d03e71ede8e94e7137777ab5ad5570c3d11b31 (patch) | |
| tree | ddd17a5e3e1c40e645772cb9466169b98389985d /src/helper_functions.c | |
| parent | 5964950ca5c018e1163fe308fa4bb17b9220b383 (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.c | 11 |
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); |
