Fixed a bug where the last character of a line would be lost when generating a list of string tokens.
This commit is contained in:
+4
-4
@@ -24,7 +24,7 @@ List* CreateList() {
|
||||
}
|
||||
|
||||
int AddListItem(const char *value, List* list) {
|
||||
if (list == NULL) return -1;
|
||||
if (!list) return -1;
|
||||
|
||||
if (list->capacity < list->size + 1) {
|
||||
void* ptr = realloc(list->root, sizeof(char*) * list->capacity * 2);
|
||||
@@ -44,7 +44,7 @@ int AddListItem(const char *value, List* list) {
|
||||
|
||||
if (!item) {
|
||||
fprintf(stderr, "Failed to malloc() new memory for '%s' (length: %lu bytes).\n", value, valueLength);
|
||||
return -1;;
|
||||
return -1;
|
||||
}
|
||||
|
||||
strncpy(item, value, valueLength);
|
||||
@@ -56,7 +56,7 @@ int AddListItem(const char *value, List* list) {
|
||||
}
|
||||
|
||||
void PrintList(const List* list) {
|
||||
if (list == NULL) return;
|
||||
if (!list) return;
|
||||
|
||||
const List *current = list;
|
||||
|
||||
@@ -68,7 +68,7 @@ void PrintList(const List* list) {
|
||||
}
|
||||
|
||||
void DestroyList(List* list) {
|
||||
if (list == NULL) return;
|
||||
if (!list) return;
|
||||
|
||||
for(int i = 0; i < list->size; i++) {
|
||||
free(list->root[i]);
|
||||
|
||||
Reference in New Issue
Block a user