Skip to content
Snippets Groups Projects
Commit 24c39856 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

simpler List_Put

parent a43164e3
No related branches found
No related tags found
No related merge requests found
...@@ -134,12 +134,18 @@ void List_Write(List_T * liste, int index, void *data) ...@@ -134,12 +134,18 @@ void List_Write(List_T * liste, int index, void *data)
void List_Put(List_T * liste, int index, void *data) void List_Put(List_T * liste, int index, void *data)
{ {
liste->n += 1; if(index < 0)
Msg::Error("Wrong list index (put)");
else {
if(index >= liste->n) {
liste->n = index + 1;
List_Realloc(liste, liste->n); List_Realloc(liste, liste->n);
for(int j = 0; j < liste->n -1 - index; j++) List_Write(liste, index, data);
memcpy(List_Pointer_Fast(liste, liste->n - j - 1), List_Pointer_Fast(liste, liste->n - 1 - j - 1), }
liste->size); else {
memcpy(&liste->array[index * liste->size], data, liste->size); List_Write(liste, index, data);
}
}
} }
void List_Pop(List_T * liste) void List_Pop(List_T * liste)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment