macsim/src/noc/msgqueue.c
// Add a message to the end of a queue
Add a message to the end of a queue
Add a message to the end of a queue
bool msg_enqueue(msg_queue_t *queue, uint8_t *buf, uint32_min_t len, rank_t rank)
{
    msg_queue_entry_t *n = malloc(sizeof(msg_queue_entry_t)-MAX_MSG_LEN+len);
    if (!n) return 0; 
    n->next = 0;
    n->rank = rank;
    n->len = len;
    memcpy(n->content, buf, len);
    if (queue->tail)
    {
	queue->tail->next = n;
	queue->tail = n;
    }
    else
	queue->tail = queue->head = n;
    queue->count++;
    return 1;
}
bool msg_enqueue ( msg_queue_t * queue , uint8_t * buf , uint32_min_t len , rank_t rank ) { msg_queue_entry_t * n = malloc ( sizeof ( msg_queue_entry_t ) - MAX_MSG_LEN + len ) ; if ( ! n ) return 0 ; n -> next = 0 ; n -> rank = rank ; n -> len = len ; memcpy ( n -> content , buf , len ) ; if ( queue -> tail ) { queue -> tail -> next = n ; queue -> tail = n ; } else queue -> tail = queue -> head = n ; queue -> count ++ ; return 1 ; }
Add a message to the end of a queue
Add a message to the end of a queue
// Out of memory