diff --git a/communication_techniques/src/communication/csq.c b/communication_techniques/src/communication/csq.c index 70c49a2..22b9060 100644 --- a/communication_techniques/src/communication/csq.c +++ b/communication_techniques/src/communication/csq.c @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -89,21 +90,16 @@ void *recv_one_data(void) ssize_t recv_some_data(void **buf, size_t count) { - int i, n; + int n; n = 0; // If all slots are empty, spin while (comm->queue[ctrl.head].flag) { // Dequeue a chunk of data items - for (i = 0; i < SUB_SLOTS; i++) - { - /* - * The behaviour of this is not documented but we know - * the values inside buf won't change during this affectation - */ - *buf++ = comm->queue[ctrl.head].chunk[i]; - } + memcpy(buf, (const void *) + comm->queue[ctrl.head].chunk, + SUB_SLOTS * sizeof(*buf)); n += SUB_SLOTS; comm->queue[ctrl.head].flag = 0; ctrl.head = (ctrl.head + 1) % SLOTS;