Fixed adding message to data list before receiving messages

This commit is contained in:
n07070 2020-04-28 19:51:53 +02:00
parent fd623ee484
commit fae758e4dd

View File

@ -229,7 +229,13 @@ int add_data(unsigned char len, int64_t id, int16_t seqno, char *data) {
// If the data list has never been used, or is empty ( same thing )
if (data_list == NULL) {
data_list = (list*) malloc(sizeof(struct list));
}
list *tmp = data_list;
// We create the next node of the linked list.
tmp->data = (void *) message;
tmp->next = NULL;
} else {
// we move until the last element of the dala_list,
// and add or data there.
// We use a temporary address to avoid writing to the static list.
@ -245,7 +251,7 @@ int add_data(unsigned char len, int64_t id, int16_t seqno, char *data) {
// Adding the message to the list.
tmp->next = (void *) new_node;
}
return 1;
} else {
// Copy data