msh

simple shell implementation
Index Commits Files Refs README LICENSE
commit f0dfe89d1ccfe7ba26fcd91f381475b77387934a
parent a10a3b1d7d3fc67c4ed237d652d64dc472718d16
Author: mjkloeckner <martinjkloeckner@gmail.com>
Date:   Mon,  8 May 2023 01:02:53 -0300

make tokens_alloc growth assign inline

Diffstat:
Mmsh.c | 3+--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/msh.c b/msh.c
@@ -54,8 +54,7 @@ char **buffer_split(char *b, char **t) {
     tokens_count = 0;
     for(p = b; (p = strtok(p, TOKENS_DELIM)); p = NULL) {
         if((tokens_count + 1) == tokens_alloc) {
-            tokens_alloc += tokens_alloc;
-            if(!(aux = realloc(t, sizeof(char*) * tokens_alloc))) {
+            if(!(aux = realloc(t, sizeof(char*) * (tokens_alloc *= 2)))) {
                 perror("msh");
                 for(size_t i = 0; i < tokens_count; i++)
                     free(t[i]);