Skip to content
Snippets Groups Projects
Commit 4377ff00 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

More Borland happiness

Sadness for the rest of the world.
parent 1ac81432
No related branches found
No related tags found
No related merge requests found
Pipeline #8021 failed
...@@ -8,6 +8,8 @@ named_string_t * ...@@ -8,6 +8,8 @@ named_string_t *
namedStrListInsert(named_string_t ***list, const char *name, const char *value, size_t index) namedStrListInsert(named_string_t ***list, const char *name, const char *value, size_t index)
{ {
size_t count; size_t count;
named_string_t **newlist;
COUNT_LIST_ITEMS((*list), count); COUNT_LIST_ITEMS((*list), count);
if (count == NAMED_STR_LIST_LAST_INDEX) if (count == NAMED_STR_LIST_LAST_INDEX)
return NULL; return NULL;
...@@ -15,7 +17,7 @@ namedStrListInsert(named_string_t ***list, const char *name, const char *value, ...@@ -15,7 +17,7 @@ namedStrListInsert(named_string_t ***list, const char *name, const char *value,
index = count; index = count;
if (index > count) if (index > count)
index = count; index = count;
named_string_t **newlist = (named_string_t **)realloc(*list, (count + 2) * sizeof(named_string_t*)); newlist = (named_string_t **)realloc(*list, (count + 2) * sizeof(named_string_t*));
if (newlist == NULL) if (newlist == NULL)
return NULL; return NULL;
*list = newlist; *list = newlist;
...@@ -33,15 +35,18 @@ bool ...@@ -33,15 +35,18 @@ bool
namedStrListDelete(named_string_t ***list, size_t index) namedStrListDelete(named_string_t ***list, size_t index)
{ {
size_t count; size_t count;
named_string_t *old;
named_string_t **newlist;
COUNT_LIST_ITEMS(*list, count); COUNT_LIST_ITEMS(*list, count);
if (index == NAMED_STR_LIST_LAST_INDEX) if (index == NAMED_STR_LIST_LAST_INDEX)
index = count - 1; index = count - 1;
if (index >= count) if (index >= count)
return false; return false;
named_string_t **newlist = (named_string_t **)realloc(*list, (count + 1) * sizeof(named_string_t*)); newlist = (named_string_t **)realloc(*list, (count + 1) * sizeof(named_string_t*));
if (newlist != NULL) if (newlist != NULL)
*list = newlist; *list = newlist;
named_string_t *old = (*list)[index]; *old = (*list)[index];
memmove(&(*list)[index], &(*list)[index + 1], (count - index) * sizeof(named_string_t*)); memmove(&(*list)[index], &(*list)[index + 1], (count - index) * sizeof(named_string_t*));
free(old->name); free(old->name);
free(old->value); free(old->value);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment