createmailbox.cpp

来自「一个很棒的网络控制系统仿真软件」· C++ 代码 · 共 50 行

CPP
50
字号
#ifndef CREATE_MAILBOX#define CREATE_MAILBOXbool ttCreateMailbox(char *nameOfMailbox, int maxSize) {  MailboxNode* mn;  Mailbox* m;    if (strcmp(nameOfMailbox,"") == 0) {    MEX_ERROR("ttCreateMailbox: Name should be a non-empty string!");    return false;  }  if (rtsys->prioFcn == NULL) {    MEX_ERROR("ttCreateMailbox: Kernel must be initialized before creation of mailboxes!");    return false;  }   mn = (MailboxNode*) rtsys->mailboxList->getFirst();  while (mn!=NULL) {    if (mn->getMailbox()->name != NULL) {      if (strcmp(mn->getMailbox()->name, nameOfMailbox) == 0)	break;    }    mn = (MailboxNode*) mn->getNext();  }  if (mn != NULL) {     MEX_ERROR("ttCreateMailbox: Name of mailbox not unique!");    return false;  }  if (maxSize < 1) {    MEX_ERROR("ttCreateMailbox: Size of mailbox must be greater than zero!");    return false;  }  m = new Mailbox;  m->name = new char[strlen(nameOfMailbox)+1];  strcpy(m->name, nameOfMailbox);  m->maxSize = maxSize;  m->buffer = new void*[maxSize];  m->inP = 0;  m->outP = 0;  m->count = 0;  rtsys->mailboxList->appendNode(new MailboxNode(m));	  return true;}#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?