|
@@ -1228,18 +1228,17 @@ static UA_StatusCode
|
|
|
deleteOneWayReference(UA_Server *server, UA_Session *session, UA_Node *node,
|
|
|
const UA_DeleteReferencesItem *item) {
|
|
|
UA_Boolean edited = false;
|
|
|
- for(size_t i = node->referencesSize-1; ; --i) {
|
|
|
- if(i > node->referencesSize)
|
|
|
- break; /* underflow after i == 0 */
|
|
|
- if(!UA_NodeId_equal(&item->targetNodeId.nodeId, &node->references[i].targetId.nodeId))
|
|
|
+ for(size_t i = node->referencesSize; i > 0; --i) {
|
|
|
+ UA_ReferenceNode *ref = &node->references[i-1];
|
|
|
+ if(!UA_NodeId_equal(&item->targetNodeId.nodeId, &ref->targetId.nodeId))
|
|
|
continue;
|
|
|
- if(!UA_NodeId_equal(&item->referenceTypeId, &node->references[i].referenceTypeId))
|
|
|
+ if(!UA_NodeId_equal(&item->referenceTypeId, &ref->referenceTypeId))
|
|
|
continue;
|
|
|
- if(item->isForward == node->references[i].isInverse)
|
|
|
+ if(item->isForward == ref->isInverse)
|
|
|
continue;
|
|
|
+ UA_ReferenceNode_deleteMembers(ref);
|
|
|
/* move the last entry to override the current position */
|
|
|
- UA_ReferenceNode_deleteMembers(&node->references[i]);
|
|
|
- node->references[i] = node->references[node->referencesSize-1];
|
|
|
+ node->references[i-1] = node->references[node->referencesSize-1];
|
|
|
--node->referencesSize;
|
|
|
edited = true;
|
|
|
break;
|