Fixed adding message to data list before receiving messages
This commit is contained in:
parent
fd623ee484
commit
fae758e4dd
10
src/node.c
10
src/node.c
@ -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 the data list has never been used, or is empty ( same thing )
|
||||||
if (data_list == NULL) {
|
if (data_list == NULL) {
|
||||||
data_list = (list*) malloc(sizeof(struct list));
|
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,
|
// we move until the last element of the dala_list,
|
||||||
// and add or data there.
|
// and add or data there.
|
||||||
// We use a temporary address to avoid writing to the static list.
|
// 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.
|
// Adding the message to the list.
|
||||||
tmp->next = (void *) new_node;
|
tmp->next = (void *) new_node;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
// Copy data
|
// Copy data
|
||||||
|
Loading…
Reference in New Issue
Block a user