Kaynağa Gözat

clean up namespace and fix a bug in testing

Julius Pfrommer 10 yıl önce
ebeveyn
işleme
eb471f8a7f

+ 35 - 35
src/ua_application.c

@@ -82,7 +82,7 @@ void appMockup_init() {
 	references->description = UA_LOCALIZEDTEXT_STATIC("References");
 	references->isAbstract = UA_TRUE;
 	references->symmetric = UA_TRUE;
-	Namespace_insert(ns0,(const UA_Node**)&references, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&references, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *hierarchicalreferences;
 	UA_ReferenceTypeNode_new(&hierarchicalreferences);
@@ -95,7 +95,7 @@ void appMockup_init() {
 	hierarchicalreferences->symmetric = UA_FALSE;
 	AddReference((UA_Node*)hierarchicalreferences, &(UA_ReferenceNode){RefTypeId_HasSubtype, UA_TRUE,
 		(UA_ExpandedNodeId){RefTypeId_References, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&hierarchicalreferences, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&hierarchicalreferences, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *nonhierarchicalreferences;
 	UA_ReferenceTypeNode_new(&nonhierarchicalreferences);
@@ -108,7 +108,7 @@ void appMockup_init() {
 	nonhierarchicalreferences->symmetric = UA_FALSE;
 	AddReference((UA_Node*)nonhierarchicalreferences, &(UA_ReferenceNode){RefTypeId_HasSubtype, UA_TRUE,
 		(UA_ExpandedNodeId){RefTypeId_References, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&nonhierarchicalreferences, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&nonhierarchicalreferences, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *haschild;
 	UA_ReferenceTypeNode_new(&haschild);
@@ -121,7 +121,7 @@ void appMockup_init() {
 	haschild->symmetric = UA_FALSE;
 	AddReference((UA_Node*)haschild, &(UA_ReferenceNode){RefTypeId_HasSubtype, UA_TRUE,
 		(UA_ExpandedNodeId){RefTypeId_HierarchicalReferences, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&haschild, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&haschild, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *organizes;
 	UA_ReferenceTypeNode_new(&organizes);
@@ -135,7 +135,7 @@ void appMockup_init() {
 	organizes->inverseName = UA_LOCALIZEDTEXT_STATIC("OrganizedBy");
 	AddReference((UA_Node*)organizes, &(UA_ReferenceNode){RefTypeId_HasSubtype, UA_TRUE,
 		(UA_ExpandedNodeId){RefTypeId_HierarchicalReferences, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&organizes, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&organizes, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *haseventsource;
 	UA_ReferenceTypeNode_new(&haseventsource);
@@ -149,7 +149,7 @@ void appMockup_init() {
 	haseventsource->inverseName = UA_LOCALIZEDTEXT_STATIC("EventSourceOf");
 	AddReference((UA_Node*)haseventsource, &(UA_ReferenceNode){RefTypeId_HasSubtype, UA_TRUE,
 		(UA_ExpandedNodeId){RefTypeId_HierarchicalReferences, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&haseventsource, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&haseventsource, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *hasmodellingrule;
 	UA_ReferenceTypeNode_new(&hasmodellingrule);
@@ -163,7 +163,7 @@ void appMockup_init() {
 	hasmodellingrule->inverseName = UA_LOCALIZEDTEXT_STATIC("ModellingRuleOf");
 	AddReference((UA_Node*)hasmodellingrule, &(UA_ReferenceNode){RefTypeId_HasSubtype, UA_TRUE,
 		(UA_ExpandedNodeId){RefTypeId_NonHierarchicalReferences, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&hasmodellingrule, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&hasmodellingrule, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *hasencoding;
 	UA_ReferenceTypeNode_new(&hasencoding);
@@ -177,7 +177,7 @@ void appMockup_init() {
 	hasencoding->inverseName = UA_LOCALIZEDTEXT_STATIC("EncodingOf");
 	AddReference((UA_Node*)hasencoding, &(UA_ReferenceNode){RefTypeId_HasSubtype, UA_TRUE,
 		(UA_ExpandedNodeId){RefTypeId_NonHierarchicalReferences, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&hasencoding, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&hasencoding, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *hasdescription;
 	UA_ReferenceTypeNode_new(&hasdescription);
@@ -191,7 +191,7 @@ void appMockup_init() {
 	hasdescription->inverseName = UA_LOCALIZEDTEXT_STATIC("DescriptionOf");
 	AddReference((UA_Node*)hasdescription, &(UA_ReferenceNode){RefTypeId_HasSubtype, UA_TRUE,
 		(UA_ExpandedNodeId){RefTypeId_NonHierarchicalReferences, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&hasdescription, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&hasdescription, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *hastypedefinition;
 	UA_ReferenceTypeNode_new(&hastypedefinition);
@@ -205,7 +205,7 @@ void appMockup_init() {
 	hastypedefinition->inverseName = UA_LOCALIZEDTEXT_STATIC("TypeDefinitionOf");
 	AddReference((UA_Node*)hastypedefinition, &(UA_ReferenceNode){RefTypeId_HasSubtype, UA_TRUE,
 		(UA_ExpandedNodeId){RefTypeId_NonHierarchicalReferences, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&hastypedefinition, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&hastypedefinition, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *generatesevent;
 	UA_ReferenceTypeNode_new(&generatesevent);
@@ -219,7 +219,7 @@ void appMockup_init() {
 	generatesevent->inverseName = UA_LOCALIZEDTEXT_STATIC("GeneratedBy");
 	AddReference((UA_Node*)generatesevent, &(UA_ReferenceNode){RefTypeId_HasSubtype, UA_TRUE,
 		(UA_ExpandedNodeId){RefTypeId_NonHierarchicalReferences, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&generatesevent, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&generatesevent, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *aggregates;
 	UA_ReferenceTypeNode_new(&aggregates);
@@ -232,7 +232,7 @@ void appMockup_init() {
 	aggregates->symmetric = UA_FALSE;
 	AddReference((UA_Node*)aggregates, &(UA_ReferenceNode){RefTypeId_HasSubtype, UA_TRUE,
 		(UA_ExpandedNodeId){RefTypeId_HasChild, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&aggregates, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&aggregates, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *hassubtype;
 	UA_ReferenceTypeNode_new(&hassubtype);
@@ -246,7 +246,7 @@ void appMockup_init() {
 	hassubtype->inverseName = UA_LOCALIZEDTEXT_STATIC("SubtypeOf");
 	AddReference((UA_Node*)hassubtype, &(UA_ReferenceNode){RefTypeId_HasSubtype, UA_TRUE,
 		(UA_ExpandedNodeId){RefTypeId_HasChild, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&hassubtype, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&hassubtype, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *hasproperty;
 	UA_ReferenceTypeNode_new(&hasproperty);
@@ -260,7 +260,7 @@ void appMockup_init() {
 	hasproperty->inverseName = UA_LOCALIZEDTEXT_STATIC("PropertyOf");
 	AddReference((UA_Node*)hasproperty, &(UA_ReferenceNode){RefTypeId_HasSubtype, UA_TRUE,
 		(UA_ExpandedNodeId){RefTypeId_Aggregates, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&hasproperty, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&hasproperty, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *hascomponent;
 	UA_ReferenceTypeNode_new(&hascomponent);
@@ -274,7 +274,7 @@ void appMockup_init() {
 	hascomponent->inverseName = UA_LOCALIZEDTEXT_STATIC("ComponentOf");
 	AddReference((UA_Node*)hascomponent, &(UA_ReferenceNode){RefTypeId_HasSubtype, UA_TRUE,
 		(UA_ExpandedNodeId){RefTypeId_Aggregates, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&hascomponent, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&hascomponent, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *hasnotifier;
 	UA_ReferenceTypeNode_new(&hasnotifier);
@@ -288,7 +288,7 @@ void appMockup_init() {
 	hasnotifier->inverseName = UA_LOCALIZEDTEXT_STATIC("NotifierOf");
 	AddReference((UA_Node*)hasnotifier, &(UA_ReferenceNode){RefTypeId_HasSubtype, UA_TRUE,
 		(UA_ExpandedNodeId){RefTypeId_HasEventSource, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&hasnotifier, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&hasnotifier, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *hasorderedcomponent;
 	UA_ReferenceTypeNode_new(&hasorderedcomponent);
@@ -302,7 +302,7 @@ void appMockup_init() {
 	hasorderedcomponent->inverseName = UA_LOCALIZEDTEXT_STATIC("OrderedComponentOf");
 	AddReference((UA_Node*)hasorderedcomponent, &(UA_ReferenceNode){RefTypeId_HasSubtype, UA_TRUE,
 		(UA_ExpandedNodeId){RefTypeId_HasComponent, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&hasorderedcomponent, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&hasorderedcomponent, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *hasmodelparent;
 	UA_ReferenceTypeNode_new(&hasmodelparent);
@@ -316,7 +316,7 @@ void appMockup_init() {
 	hasmodelparent->inverseName = UA_LOCALIZEDTEXT_STATIC("ModelParentOf");
 	AddReference((UA_Node*)hasmodelparent, &(UA_ReferenceNode){RefTypeId_HasSubtype, UA_TRUE,
 		(UA_ExpandedNodeId){RefTypeId_NonHierarchicalReferences, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&hasmodelparent, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&hasmodelparent, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *fromstate;
 	UA_ReferenceTypeNode_new(&fromstate);
@@ -330,7 +330,7 @@ void appMockup_init() {
 	fromstate->inverseName = UA_LOCALIZEDTEXT_STATIC("ToTransition");
 	AddReference((UA_Node*)fromstate, &(UA_ReferenceNode){RefTypeId_HasSubtype, UA_TRUE,
 		(UA_ExpandedNodeId){RefTypeId_NonHierarchicalReferences, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&fromstate, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&fromstate, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *tostate;
 	UA_ReferenceTypeNode_new(&tostate);
@@ -344,7 +344,7 @@ void appMockup_init() {
 	tostate->inverseName = UA_LOCALIZEDTEXT_STATIC("FromTransition");
 	AddReference((UA_Node*)tostate, &(UA_ReferenceNode){RefTypeId_HasSubtype, UA_TRUE,
 		(UA_ExpandedNodeId){RefTypeId_NonHierarchicalReferences, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&tostate, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&tostate, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *hascause;
 	UA_ReferenceTypeNode_new(&hascause);
@@ -358,7 +358,7 @@ void appMockup_init() {
 	hascause->inverseName = UA_LOCALIZEDTEXT_STATIC("MayBeCausedBy");
 	AddReference((UA_Node*)hascause, &(UA_ReferenceNode){RefTypeId_HasSubtype, UA_TRUE,
 		(UA_ExpandedNodeId){RefTypeId_NonHierarchicalReferences, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&hascause, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&hascause, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *haseffect;
 	UA_ReferenceTypeNode_new(&haseffect);
@@ -372,7 +372,7 @@ void appMockup_init() {
 	haseffect->inverseName = UA_LOCALIZEDTEXT_STATIC("MayBeEffectedBy");
 	AddReference((UA_Node*)haseffect, &(UA_ReferenceNode){RefTypeId_HasSubtype, UA_TRUE,
 		(UA_ExpandedNodeId){RefTypeId_NonHierarchicalReferences, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&haseffect, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&haseffect, NAMESPACE_INSERT_UNIQUE);
 
 	UA_ReferenceTypeNode *hashistoricalconfiguration;
 	UA_ReferenceTypeNode_new(&hashistoricalconfiguration);
@@ -386,7 +386,7 @@ void appMockup_init() {
 	hashistoricalconfiguration->inverseName = UA_LOCALIZEDTEXT_STATIC("HistoricalConfigurationOf");
 	AddReference((UA_Node*)hashistoricalconfiguration, &(UA_ReferenceNode){RefTypeId_HasSubtype,
 		UA_TRUE, (UA_ExpandedNodeId){RefTypeId_Aggregates, UA_STRING_NULL, 0}}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&hashistoricalconfiguration, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&hashistoricalconfiguration, NAMESPACE_INSERT_UNIQUE);
 
 
 	// ObjectTypes (Ids only)
@@ -411,7 +411,7 @@ void appMockup_init() {
 	folderType->browseName = UA_QUALIFIEDNAME_STATIC("FolderType");
 	folderType->displayName = UA_LOCALIZEDTEXT_STATIC("FolderType");
 	folderType->description = UA_LOCALIZEDTEXT_STATIC("FolderType");
-	Namespace_insert(ns0,(const UA_Node**)&folderType, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&folderType, NAMESPACE_INSERT_UNIQUE);
 
 	// Root
 	UA_ObjectNode *root;
@@ -426,7 +426,7 @@ void appMockup_init() {
 	AddReference((UA_Node*)root, &(UA_ReferenceNode){RefTypeId_Organizes, UA_FALSE, ObjId_TypesFolder}, ns0);
 	AddReference((UA_Node*)root, &(UA_ReferenceNode){RefTypeId_Organizes, UA_FALSE, ObjId_ViewsFolder}, ns0);
 	/* root becomes a managed node. we need to release it at the end.*/
-	Namespace_insert(ns0,(const UA_Node**)&root, NAMESPACE_INSERT_UNIQUE | NAMESPACE_INSERT_GETMANAGED);
+	Namespace_insert(ns0,(UA_Node**)&root, NAMESPACE_INSERT_UNIQUE | NAMESPACE_INSERT_GETMANAGED);
 
 	// Objects
 	UA_ObjectNode *objects;
@@ -438,7 +438,7 @@ void appMockup_init() {
 	objects->description = UA_LOCALIZEDTEXT_STATIC("Objects");
 	AddReference((UA_Node*)objects, &(UA_ReferenceNode){RefTypeId_HasTypeDefinition, UA_FALSE, ObjTypeId_FolderType}, ns0);
 	AddReference((UA_Node*)objects, &(UA_ReferenceNode){RefTypeId_Organizes, UA_FALSE, ObjId_Server}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&objects, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&objects, NAMESPACE_INSERT_UNIQUE);
 
 	// Types
 	UA_ObjectNode *types;
@@ -449,7 +449,7 @@ void appMockup_init() {
 	types->displayName = UA_LOCALIZEDTEXT_STATIC("Types");
 	types->description = UA_LOCALIZEDTEXT_STATIC("Types");
 	AddReference((UA_Node*)types, &(UA_ReferenceNode){RefTypeId_HasTypeDefinition, UA_FALSE, ObjTypeId_FolderType}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&types, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&types, NAMESPACE_INSERT_UNIQUE);
 
 	// Views
 	UA_ObjectNode *views;
@@ -460,7 +460,7 @@ void appMockup_init() {
 	views->displayName = UA_LOCALIZEDTEXT_STATIC("Views");
 	views->description = UA_LOCALIZEDTEXT_STATIC("Views");
 	AddReference((UA_Node*)views, &(UA_ReferenceNode){RefTypeId_HasTypeDefinition, UA_FALSE, ObjTypeId_FolderType}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&views, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&views, NAMESPACE_INSERT_UNIQUE);
 
 	// Server
 	UA_ObjectNode *server;
@@ -474,7 +474,7 @@ void appMockup_init() {
 	AddReference((UA_Node*)server, &(UA_ReferenceNode){RefTypeId_HasComponent, UA_FALSE, ObjId_NamespaceArray}, ns0);
 	AddReference((UA_Node*)server, &(UA_ReferenceNode){RefTypeId_HasProperty, UA_FALSE, ObjId_ServerStatus}, ns0);
 	AddReference((UA_Node*)server, &(UA_ReferenceNode){RefTypeId_HasProperty, UA_FALSE, ObjId_ServerArray}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&server, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&server, NAMESPACE_INSERT_UNIQUE);
 
 	// NamespaceArray
 	UA_VariableNode *namespaceArray;
@@ -498,7 +498,7 @@ void appMockup_init() {
 	namespaceArray->valueRank = 1;
 	namespaceArray->minimumSamplingInterval = 1.0;
 	namespaceArray->historizing = UA_FALSE;
-	Namespace_insert(ns0,(const UA_Node**)&namespaceArray, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&namespaceArray, NAMESPACE_INSERT_UNIQUE);
 
 	// ServerStatus
 	UA_VariableNode *serverstatus;
@@ -525,7 +525,7 @@ void appMockup_init() {
 	serverstatus->value.vt = &UA_.types[UA_SERVERSTATUSDATATYPE]; // gets encoded as an extensionobject
 	serverstatus->value.arrayLength = 1;
 	serverstatus->value.data = status;
-	Namespace_insert(ns0,(const UA_Node**)&serverstatus, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&serverstatus, NAMESPACE_INSERT_UNIQUE);
 
 	// State (Component of ServerStatus)
 	UA_VariableNode *state;
@@ -538,7 +538,7 @@ void appMockup_init() {
 	state->value.vt = &UA_borrowed_.types[UA_SERVERSTATE];
 	state->value.arrayLength = 1;
 	state->value.data = &status->state; // points into the other object.
-	Namespace_insert(ns0,(const UA_Node**)&state, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&state, NAMESPACE_INSERT_UNIQUE);
 
 	//TODO: free(namespaceArray->value.data) later or forget it
 
@@ -584,7 +584,7 @@ void appMockup_init() {
 	tmpNodeValue->vt = &UA_.types[UA_FLOAT];
 
 	AddReference((UA_Node*)root, &(UA_ReferenceNode){RefTypeId_Organizes, UA_FALSE, ObjId_temperature1}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&temperature1, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&temperature1, NAMESPACE_INSERT_UNIQUE);
 
 
 	UA_ExpandedNodeId ObjId_redLED = (UA_ExpandedNodeId){.nodeId = (UA_NodeId){.encodingByte = UA_NODEIDTYPE_TWOBYTE, .namespace = 0, .identifier.numeric = 109}, .namespaceUri = {-1, ((void *)0)}, .serverIndex = 0};
@@ -609,7 +609,7 @@ void appMockup_init() {
 	tmpNodeValue1->vt = &UA_.types[UA_BOOLEAN];
 
 	AddReference((UA_Node*)root, &(UA_ReferenceNode){RefTypeId_Organizes, UA_FALSE, ObjId_redLED}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&redLED, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&redLED, NAMESPACE_INSERT_UNIQUE);
 
 
 	UA_ExpandedNodeId ObjId_yellowLED = (UA_ExpandedNodeId){.nodeId = (UA_NodeId){.encodingByte = UA_NODEIDTYPE_TWOBYTE, .namespace = 0, .identifier.numeric = 110}, .namespaceUri = {-1, ((void *)0)}, .serverIndex = 0};
@@ -634,7 +634,7 @@ void appMockup_init() {
 	tmpNodeValue2->vt = &UA_.types[UA_BOOLEAN];
 
 	AddReference((UA_Node*)root, &(UA_ReferenceNode){RefTypeId_Organizes, UA_FALSE, ObjId_yellowLED}, ns0);
-	Namespace_insert(ns0,(const UA_Node**)&yellowLED, NAMESPACE_INSERT_UNIQUE);
+	Namespace_insert(ns0,(UA_Node**)&yellowLED, NAMESPACE_INSERT_UNIQUE);
 	
 	Namespace_releaseManagedNode((const UA_Node*)root);
 

+ 1 - 1
src/ua_namespace.c

@@ -263,7 +263,7 @@ UA_Int32 Namespace_delete(Namespace * ns) {
 	return UA_SUCCESS;
 }
 
-UA_Int32 Namespace_insert(Namespace *ns, const UA_Node **node, UA_Byte flags) {
+UA_Int32 Namespace_insert(Namespace *ns, UA_Node **node, UA_Byte flags) {
 	if(ns == UA_NULL || node == UA_NULL || *node == UA_NULL)
 		return UA_ERROR;
 	

+ 1 - 1
src/ua_namespace.h

@@ -38,7 +38,7 @@ UA_Int32 Namespace_delete(Namespace *ns);
     With the UNIQUE flag, the node is only inserted if the nodeid does not
     already exist. With the GETMANAGED flag, the node pointer is replaced with
     the managed pointer. Otherwise, it is set to UA_NULL. */
-UA_Int32 Namespace_insert(Namespace *ns, const UA_Node **node, UA_Byte flags);
+UA_Int32 Namespace_insert(Namespace *ns, UA_Node **node, UA_Byte flags);
 
 /** @brief Remove a node from the namespace. Always succeeds, even if the node
 	was not found. */

+ 18 - 11
src/ua_namespace_concurrent.c

@@ -8,6 +8,7 @@
 #define ALIVE_BIT (1 << 15) /* Alive bit in the readcount */
 typedef struct Namespace_Entry {
 	struct cds_lfht_node htn; /* contains next-ptr for urcu-hashmap */
+	struct rcu_head rcu_head; /* For call-rcu */
 	UA_UInt16 readcount;      /* Counts the amount of readers on it [alive-bit, 15 counter-bits] */
 	UA_Node   node;           /* Might be cast from any _bigger_ UA_Node* type. Allocate enough memory! */
 } Namespace_Entry;
@@ -151,7 +152,8 @@ static int compare(struct cds_lfht_node *htn, const void *orig) {
    all readers using the node for a longer time (outside the rcu critical
    section) increased the readcount, we only need to wait for the readcount
    to reach zero. */
-static void markDead(Namespace_Entry *entry) {
+static void markDead(struct rcu_head *head) {
+	Namespace_Entry *entry = caa_container_of(head, Namespace_Entry, rcu_head);
 	if(uatomic_sub_return(&entry->readcount, ALIVE_BIT) > 0)
 		return;
 
@@ -165,7 +167,7 @@ void Namespace_releaseManagedNode(const UA_Node *managed) {
 	if(managed == UA_NULL)
 		return;
 	
-	Namespace_Entry *entry = caa_container_of(managed, Namespace_Entry, htn); // pointer to the first entry
+	Namespace_Entry *entry = caa_container_of(managed, Namespace_Entry, node); // pointer to the first entry
 	if(uatomic_sub_return(&entry->readcount, 1) > 0)
 		return;
 
@@ -203,8 +205,10 @@ UA_Int32 Namespace_delete(Namespace *ns) {
 	cds_lfht_first(ht, &iter);
 	while(iter.node != UA_NULL) {
 		found_htn = cds_lfht_iter_get_node(&iter);
-		if(!cds_lfht_del(ht, found_htn))
-			call_rcu(found_htn, markDead);
+		if(!cds_lfht_del(ht, found_htn)) {
+			Namespace_Entry *entry = caa_container_of(found_htn, Namespace_Entry, htn);
+			call_rcu(&entry->rcu_head, markDead);
+		}
 		cds_lfht_next(ht, &iter);
 	}
 	rcu_read_unlock();
@@ -217,7 +221,7 @@ UA_Int32 Namespace_delete(Namespace *ns) {
 		return UA_ERROR;
 }
 
-UA_Int32 Namespace_insert(Namespace *ns, const UA_Node **node, UA_Byte flags) {
+UA_Int32 Namespace_insert(Namespace *ns, UA_Node **node, UA_Byte flags) {
 	if(ns == UA_NULL || node == UA_NULL || *node == UA_NULL || (*node)->nodeId.namespace != ns->namespaceId)
 		return UA_ERROR;
 
@@ -261,7 +265,7 @@ UA_Int32 Namespace_insert(Namespace *ns, const UA_Node **node, UA_Byte flags) {
 	}
 
 	Namespace_Entry *entry;
-	if(UA_alloc((void **)&entry, sizeof(struct cds_lfht_node) + sizeof(UA_UInt16) + nodesize))
+	if(UA_alloc((void **)&entry, sizeof(Namespace_Entry) - sizeof(UA_Node) + nodesize))
 		return UA_ERR_NO_MEMORY;
 	memcpy(&entry->node, *node, nodesize);
 
@@ -286,8 +290,10 @@ UA_Int32 Namespace_insert(Namespace *ns, const UA_Node **node, UA_Byte flags) {
 		rcu_read_lock();
 		result = cds_lfht_add_replace(ns->ht, nhash, compare, &(*node)->nodeId, &entry->htn);
 		/* If an entry got replaced, mark it as dead. */
-		if(result)
-			call_rcu(markDead, result);      /* Queue this for the next time when no readers are on the entry.*/
+		if(result) {
+			Namespace_Entry *entry = caa_container_of(result, Namespace_Entry, htn);
+			call_rcu(&entry->rcu_head, markDead);      /* Queue this for the next time when no readers are on the entry.*/
+		}
 		rcu_read_unlock();
 	}
 
@@ -306,15 +312,16 @@ UA_Int32 Namespace_remove(Namespace *ns, const UA_NodeId *nodeid) {
 
 	rcu_read_lock();
 	cds_lfht_lookup(ns->ht, nhash, compare, &nodeid, &iter);
-	struct cds_lfht_node *found_node = cds_lfht_iter_get_node(&iter);
+	struct cds_lfht_node *found_htn = cds_lfht_iter_get_node(&iter);
 
 	/* If this fails, then the node has already been removed. */
-	if(!found_node || cds_lfht_del(ns->ht, found_node) != 0) {
+	if(!found_htn || cds_lfht_del(ns->ht, found_htn) != 0) {
 		rcu_read_unlock();
 		return UA_ERROR;
 	}
 	
-	call_rcu(markDead, found_node);
+	Namespace_Entry *entry = caa_container_of(found_htn, Namespace_Entry, htn);
+	call_rcu(&entry->rcu_head, markDead);
 	rcu_read_unlock();
 
 	return UA_SUCCESS;

+ 34 - 37
tests/check_namespace.c

@@ -27,14 +27,12 @@ START_TEST(test_Namespace) {
 }
 END_TEST
 
-UA_Int32 createNode(const UA_Node** p, UA_Int16 nsid, UA_Int32 id) {
-	UA_VariableNode * p2;
-	UA_VariableNode_new(&p2);
-	p2->nodeId.encodingByte = UA_NODEIDTYPE_FOURBYTE;
-	p2->nodeId.namespace = nsid;
-	p2->nodeId.identifier.numeric = id;
-	p2->nodeClass = UA_NODECLASS_VARIABLE;
-	*p = (const UA_Node *)p2;
+UA_Int32 createNode(UA_Node** p, UA_Int16 nsid, UA_Int32 id) {
+	UA_VariableNode_new((UA_VariableNode **)p);
+	(*p)->nodeId.encodingByte = UA_NODEIDTYPE_FOURBYTE;
+	(*p)->nodeId.namespace = nsid;
+	(*p)->nodeId.identifier.numeric = id;
+	(*p)->nodeClass = UA_NODECLASS_VARIABLE;
 	return UA_SUCCESS;
 }
 
@@ -45,12 +43,12 @@ START_TEST(findNodeInNamespaceWithSingleEntry) {
 	// given
 	Namespace *ns;
 	Namespace_new(&ns, 0);
-	const UA_Node* n1; createNode(&n1,0,2253);
+	UA_Node* n1; createNode(&n1,0,2253);
 	Namespace_insert(ns, &n1, NAMESPACE_INSERT_UNIQUE | NAMESPACE_INSERT_GETMANAGED);
 	const UA_Node* nr = UA_NULL;
 	UA_Int32 retval;
 	// when
-	retval = Namespace_get(ns,&(n1->nodeId),&nr);
+	retval = Namespace_get(ns,&n1->nodeId,&nr);
 	// then
 	ck_assert_int_eq(retval, UA_SUCCESS);
 	ck_assert_ptr_eq(nr,n1);
@@ -72,18 +70,17 @@ START_TEST(failToFindNodeInOtherNamespace) {
 	Namespace *ns = UA_NULL;
 	Namespace_new(&ns, 0);
 
-	const UA_Node* n1 = UA_NULL; createNode(&n1,0,2253); Namespace_insert(ns, &n1, 0);
-	const UA_Node* n2 = UA_NULL; createNode(&n1,0,2253); Namespace_insert(ns, &n2, 0);
+	UA_Node* n1; createNode(&n1,0,2253); Namespace_insert(ns, &n1, 0);
+	UA_Node* n2; createNode(&n2,0,2253); Namespace_insert(ns, &n2, 0);
 
 	const UA_Node* nr = UA_NULL;
-	UA_Int32 retval;
 	// when
-	const UA_Node* n; createNode(&n,1,2255);
-	retval = Namespace_get(ns,&(n->nodeId), &nr);
+	UA_Node* n; createNode(&n,1,2255);
+	UA_Int32 retval = Namespace_get(ns,&n->nodeId, &nr);
 	// then
 	ck_assert_int_ne(retval, UA_SUCCESS);
 	// finally
-	UA_free((void *)n);
+	UA_Node_delete(n);
 	Namespace_releaseManagedNode(nr);
 	Namespace_delete(ns);
 #ifdef MULTITHREADING
@@ -99,12 +96,12 @@ START_TEST(findNodeInNamespaceWithSeveralEntries) {
 	// given
 	Namespace *ns;
 	Namespace_new(&ns, 0);
-	const UA_Node* n1; createNode(&n1,0,2253); Namespace_insert(ns, &n1, 0);
-	const UA_Node* n2; createNode(&n2,0,2255); Namespace_insert(ns, &n2, 0);
-	const UA_Node* n3; createNode(&n3,0,2257); Namespace_insert(ns, &n3, NAMESPACE_INSERT_GETMANAGED);
-	const UA_Node* n4; createNode(&n4,0,2200); Namespace_insert(ns, &n4, 0);
-	const UA_Node* n5; createNode(&n5,0,1); Namespace_insert(ns, &n5, 0);
-	const UA_Node* n6; createNode(&n6,0,12); Namespace_insert(ns, &n6, 0);
+	UA_Node* n1; createNode(&n1,0,2253); Namespace_insert(ns, &n1, 0);
+	UA_Node* n2; createNode(&n2,0,2255); Namespace_insert(ns, &n2, 0);
+	UA_Node* n3; createNode(&n3,0,2257); Namespace_insert(ns, &n3, NAMESPACE_INSERT_GETMANAGED);
+	UA_Node* n4; createNode(&n4,0,2200); Namespace_insert(ns, &n4, 0);
+	UA_Node* n5; createNode(&n5,0,1); Namespace_insert(ns, &n5, 0);
+	UA_Node* n6; createNode(&n6,0,12); Namespace_insert(ns, &n6, 0);
 
 	const UA_Node* nr = UA_NULL;
 	UA_Int32 retval;
@@ -130,12 +127,12 @@ START_TEST(iterateOverNamespaceShallNotVisitEmptyNodes) {
 	// given
 	Namespace *ns;
 	Namespace_new(&ns, 0);
-	const UA_Node* n1; createNode(&n1,0,2253); Namespace_insert(ns, &n1, 0);
-	const UA_Node* n2; createNode(&n2,0,2255); Namespace_insert(ns, &n2, 0);
-	const UA_Node* n3; createNode(&n3,0,2257); Namespace_insert(ns, &n3, 0);
-	const UA_Node* n4; createNode(&n4,0,2200); Namespace_insert(ns, &n4, 0);
-	const UA_Node* n5; createNode(&n5,0,1); Namespace_insert(ns, &n5, 0);
-	const UA_Node* n6; createNode(&n6,0,12); Namespace_insert(ns, &n6, 0);
+	UA_Node* n1; createNode(&n1,0,2253); Namespace_insert(ns, &n1, 0);
+	UA_Node* n2; createNode(&n2,0,2255); Namespace_insert(ns, &n2, 0);
+	UA_Node* n3; createNode(&n3,0,2257); Namespace_insert(ns, &n3, 0);
+	UA_Node* n4; createNode(&n4,0,2200); Namespace_insert(ns, &n4, 0);
+	UA_Node* n5; createNode(&n5,0,1); Namespace_insert(ns, &n5, 0);
+	UA_Node* n6; createNode(&n6,0,12); Namespace_insert(ns, &n6, 0);
 
 	UA_Int32 retval;
 	// when
@@ -161,7 +158,7 @@ START_TEST(findNodeInExpandedNamespace) {
 	// given
 	Namespace *ns;
 	Namespace_new(&ns, 0);
-	const UA_Node* n;
+	UA_Node* n;
 	UA_Int32 i=0;
 	for (; i<200; i++) {
 		createNode(&n,0,i); Namespace_insert(ns, &n, 0);
@@ -191,7 +188,7 @@ START_TEST(iterateOverExpandedNamespaceShallNotVisitEmptyNodes) {
 	// given
 	Namespace *ns;
 	Namespace_new(&ns, 0);
-	const UA_Node* n;
+	UA_Node* n;
 	UA_Int32 i=0;
 	for (; i<200; i++) {
 		createNode(&n,0,i); Namespace_insert(ns, &n, 0);
@@ -220,12 +217,12 @@ START_TEST(failToFindNonExistantNodeInNamespaceWithSeveralEntries) {
 	// given
 	Namespace *ns;
 	Namespace_new(&ns, 0);
-	const UA_Node* n1; createNode(&n1,0,2253); Namespace_insert(ns, &n1, 0);
-	const UA_Node* n2; createNode(&n2,0,2255); Namespace_insert(ns, &n2, 0);
-	const UA_Node* n3; createNode(&n3,0,2257); Namespace_insert(ns, &n3, 0);
-	const UA_Node* n4; createNode(&n4,0,2200); Namespace_insert(ns, &n4, 0);
-	const UA_Node* n5; createNode(&n5,0,1); Namespace_insert(ns, &n5, 0);
-	const UA_Node* n6; createNode(&n6,0,12); 
+	UA_Node* n1; createNode(&n1,0,2253); Namespace_insert(ns, &n1, 0);
+	UA_Node* n2; createNode(&n2,0,2255); Namespace_insert(ns, &n2, 0);
+	UA_Node* n3; createNode(&n3,0,2257); Namespace_insert(ns, &n3, 0);
+	UA_Node* n4; createNode(&n4,0,2200); Namespace_insert(ns, &n4, 0);
+	UA_Node* n5; createNode(&n5,0,1); Namespace_insert(ns, &n5, 0);
+	UA_Node* n6; createNode(&n6,0,12); 
 
 	const UA_Node* nr = UA_NULL;
 	UA_Int32 retval;
@@ -270,7 +267,7 @@ int main (void) {
 	int number_failed =0;
 	Suite *s = namespace_suite ();
 	SRunner *sr = srunner_create (s);
-	//srunner_set_fork_status(sr,CK_NOFORK);
+	srunner_set_fork_status(sr,CK_NOFORK);
 	srunner_run_all (sr, CK_NORMAL);
 	number_failed += srunner_ntests_failed (sr);
 	srunner_free (sr);