/* * *Delete a node by key(ptr->data). */ int DeleteByKey(cdlink * beg, data_t key) { cdlink *pos = FindByKey(beg, key); if (NULL == pos) return -1; Free(pos); return 0; }
/* * * Alter a node's data by Key. * */ int ChangeByKey(cdlink * beg, data_t key, data_t val) { cdlink *pos = FindByKey(beg, key); if (NULL == pos) return -1; if (-1 == Change(pos, val)) return -1; return 0; }
int InsertByKey(cdlink * beg, data_t key, data_t val) { cdlink *pos = FindByKey(beg, key); if (NULL == pos) return -1; if (-1 == Insert(pos, val)) return -1; return 0; }
void CMsgQueueHandler::MsgGet(const RMessage2& aMessage) { TInt tkey = aMessage.Int0 (); // get flag to check whether we need to creat M Q TInt tmsgflg = aMessage.Int1 (); TBool creatMq = EFalse; if ( IPC_PRIVATE == tkey) { creatMq = ETrue; } else { CMessageQueue* msqExist = FindByKey(tkey); if ( msqExist) { if ( (tmsgflg & IPC_CREAT) && ( tmsgflg & IPC_EXCL) ) { aMessage.Complete (KErrAlreadyExists); return; } //compair the operation specified //with the operation of existing flag. //coverity[result_independent_of_operands] if ( !tmsgflg || (tmsgflg | IPC_CREAT == IPC_CREAT) || msqExist->CheckPerm (tmsgflg, aMessage) ) { TBuf8<MAXINT> temp; temp.AppendNum(msqExist->UniqueId ()); aMessage.WriteL(2, temp); aMessage.Complete (KErrNone); return; } else { aMessage.Complete (KErrPermissionDenied); return; } } else { if ( tmsgflg & IPC_CREAT) { creatMq = ETrue; } else { aMessage.Complete (KErrNotFound); return; } } } if ( creatMq) { if ( KIpcMaxNumberOfQueues == iMQueue.Count ()) {//max no of message queue is achived, aMessage.Complete (KErrDiskFull); return; } //create a message queue CMessageQueue *tMsgQ = PosixIpcFactory::CreateMessageQueueL (aMessage); iMQueue.AppendL (tMsgQ); TBuf8<MAXINT> temp; temp.AppendNum (tMsgQ->UniqueId ()); aMessage.WriteL (2, temp); aMessage.Complete (KErrNone); } }