All pastes #910808 Raw Edit

Unnamed

public text v1 · immutable
·published 2008-02-20 05:50 UTC
rendered paste body
#include <pthread.h>
#include "mailboxes.h"
#include <stdlib.h>

Mailbox *mailboxes = NULL;

Mailbox* mailboxes_new_mb (pthread_t tid)
{
  Mailbox *retval, *iter;

  retval = (Mailbox *) malloc (sizeof (Mailbox));
  retval->tid = tid;
  retval->msg = NULL;
  retval->next = NULL;
  retval->cond = PTHREAD_COND_INITIALIZER;

  /* If there are no mailboxes, set this one as the list head */
  if (mailboxes == NULL)
    {
      mailboxes = retval;
      return retval;
    }

  /* Find the end of the list, and append the new mb there */
  iter = mailboxes;
  while (iter->next != NULL)
    iter = iter->next;
  iter->next = retval;

  return retval;
}

...
more code
...


The compiler error: 
mailboxes.c: In function ‘mailboxes_new_mb’:
mailboxes.c:15: error: expected expression before ‘{’ token