Skip to content

Commit

Permalink
Remove a pointer indirection in struct getNodesHandle
Browse files Browse the repository at this point in the history
  • Loading branch information
jpfr committed May 24, 2018
1 parent 82e2134 commit 3e0a174
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/server/ua_subscription_events.c
Expand Up @@ -16,11 +16,9 @@ typedef struct Events_nodeListElement {
UA_NodeId nodeId;
} Events_nodeListElement;

typedef LIST_HEAD(Events_nodeList, Events_nodeListElement) Events_nodeList;

struct getNodesHandle {
UA_Server *server;
Events_nodeList *nodes;
LIST_HEAD(Events_nodeList, Events_nodeListElement) nodes;
};

/* generates a unique event id */
Expand Down Expand Up @@ -65,7 +63,7 @@ findAllSubtypesNodeIteratorCallback(UA_NodeId parentId, UA_Boolean isInverse,
return retval;
}

LIST_INSERT_HEAD(((struct getNodesHandle *) handle)->nodes, entry, listEntry);
LIST_INSERT_HEAD(&((struct getNodesHandle *) handle)->nodes, entry, listEntry);

/* recursion */
UA_Server_forEachChildNodeCall(((struct getNodesHandle *) handle)->server,
Expand All @@ -80,10 +78,8 @@ UA_Event_findVariableNode(UA_Server *server, UA_QualifiedName *name, size_t rela
const UA_NodeId *event, UA_BrowsePathResult *out) {
/* get a list with all subtypes of aggregates */
struct getNodesHandle handle;
Events_nodeList list;
LIST_INIT(&list);
handle.server = server;
handle.nodes = &list;
LIST_INIT(&handle.nodes);
UA_StatusCode retval =
UA_Server_forEachChildNodeCall(server, UA_NODEID_NUMERIC(0, UA_NS0ID_AGGREGATES),
findAllSubtypesNodeIteratorCallback, &handle);
Expand All @@ -93,7 +89,7 @@ UA_Event_findVariableNode(UA_Server *server, UA_QualifiedName *name, size_t rela
/* check if you can find the node with any of the subtypes of aggregates */
UA_Boolean nodeFound = UA_FALSE;
Events_nodeListElement *iter, *tmp_iter;
LIST_FOREACH_SAFE(iter, &list, listEntry, tmp_iter) {
LIST_FOREACH_SAFE(iter, &handle.nodes, listEntry, tmp_iter) {
if (!nodeFound) {
UA_RelativePathElement rpe;
UA_RelativePathElement_init(&rpe);
Expand Down Expand Up @@ -379,7 +375,7 @@ getParentsNodeIteratorCallback(UA_NodeId parentId, UA_Boolean isInverse,
return retval;
}

LIST_INSERT_HEAD(((struct getNodesHandle *) handle)->nodes, entry, listEntry);
LIST_INSERT_HEAD(&((struct getNodesHandle *) handle)->nodes, entry, listEntry);

/* recursion */
UA_Server_forEachChildNodeCall(((struct getNodesHandle *) handle)->server,
Expand Down Expand Up @@ -436,17 +432,15 @@ UA_Server_triggerEvent(UA_Server *server, const UA_NodeId eventNodeId, const UA_

/* get an array with all parents */
struct getNodesHandle parentHandle;
Events_nodeList parentList;
LIST_INIT(&parentList);
parentHandle.server = server;
parentHandle.nodes = &parentList;
LIST_INIT(&parentHandle.nodes);
retval = getParentsNodeIteratorCallback(origin, UA_TRUE, UA_NODEID_NULL, &parentHandle);
if(retval != UA_STATUSCODE_GOOD)
return retval;

/* add the event to each node's monitored items */
Events_nodeListElement *parentIter, *tmp_parentIter;
LIST_FOREACH_SAFE(parentIter, &parentList, listEntry, tmp_parentIter) {
LIST_FOREACH_SAFE(parentIter, &parentHandle.nodes, listEntry, tmp_parentIter) {
const UA_ObjectNode *node = (const UA_ObjectNode *) UA_Nodestore_get(server, &parentIter->nodeId);
/* SLIST_FOREACH */
for (UA_MonitoredItem *monIter = node->monitoredItemQueue; monIter != NULL; monIter = monIter->next) {
Expand Down

0 comments on commit 3e0a174

Please sign in to comment.