diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/strlist.c | 18 | 
1 files changed, 6 insertions, 12 deletions
diff --git a/src/strlist.c b/src/strlist.c index 0cad270..bdacb5a 100644 --- a/src/strlist.c +++ b/src/strlist.c @@ -215,19 +215,13 @@ void strlist_remove(struct StrList *pStrList, size_t index) {      if (count == 0) {          return;      } - -    for (size_t i = index; i < count; i++) { -        char *next = pStrList->data[i + 1]; -        if (next == NULL) { -            break; +    if (pStrList->data[index] != NULL) { +        for (size_t i = index; i < count; i++) { +            pStrList->data[i] = pStrList->data[i + 1]; +        } +        if (pStrList->num_inuse) { +            pStrList->num_inuse--;          } -        pStrList->data[i] = next; -        count = strlist_count(pStrList); -        pStrList->data[count - 1] = NULL; -    } -    if (pStrList->num_inuse) { -        guard_free(pStrList->data[pStrList->num_inuse]); -        pStrList->num_inuse--;      }  }  | 
