Pārlūkot izejas kodu

Examples: Use _clear instead of _deleteMembers for the examples

Julius Pfrommer 5 gadi atpakaļ
vecāks
revīzija
eb9409b435

+ 1 - 1
examples/access_control/client_access_control.c

@@ -59,7 +59,7 @@ int main(void) {
     printf("deleteNode returned: %s\n", UA_StatusCode_name(retCode));
 
     /* Clean up */
-    UA_VariableAttributes_deleteMembers(&newVariableAttributes);
+    UA_VariableAttributes_clear(&newVariableAttributes);
     UA_Client_delete(client); /* Disconnects the client internally */
     return UA_STATUSCODE_GOOD;
 }

+ 5 - 5
examples/client.c

@@ -81,8 +81,8 @@ int main(int argc, char *argv[]) {
             /* TODO: distinguish further types */
         }
     }
-    UA_BrowseRequest_deleteMembers(&bReq);
-    UA_BrowseResponse_deleteMembers(&bResp);
+    UA_BrowseRequest_clear(&bReq);
+    UA_BrowseResponse_clear(&bResp);
 
     /* Same thing, this time using the node iterator... */
     UA_NodeId *parent = UA_NodeId_new();
@@ -144,8 +144,8 @@ int main(int argc, char *argv[]) {
     UA_WriteResponse wResp = UA_Client_Service_write(client, wReq);
     if(wResp.responseHeader.serviceResult == UA_STATUSCODE_GOOD)
             printf("the new value is: %i\n", value);
-    UA_WriteRequest_deleteMembers(&wReq);
-    UA_WriteResponse_deleteMembers(&wResp);
+    UA_WriteRequest_clear(&wReq);
+    UA_WriteResponse_clear(&wResp);
 
     /* Write node attribute (using the highlevel API) */
     value++;
@@ -179,7 +179,7 @@ int main(int argc, char *argv[]) {
     } else {
         printf("Method call was unsuccessful, and %x returned values available.\n", retval);
     }
-    UA_Variant_deleteMembers(&input);
+    UA_Variant_clear(&input);
 #endif
 
 #ifdef UA_ENABLE_NODEMANAGEMENT

+ 65 - 74
examples/client_async.c

@@ -19,32 +19,32 @@
 /* async connection callback, it only gets called after the completion of the whole
  * connection process*/
 static void
-onConnect (UA_Client *client, void *userdata, UA_UInt32 requestId,
-           void *status) {
-    printf ("Async connect returned with status code %s\n",
-            UA_StatusCode_name (*(UA_StatusCode *) status));
+onConnect(UA_Client *client, void *userdata, UA_UInt32 requestId,
+          void *status) {
+    printf("Async connect returned with status code %s\n",
+           UA_StatusCode_name(*(UA_StatusCode *) status));
 }
 
 static
 void
-fileBrowsed (UA_Client *client, void *userdata, UA_UInt32 requestId,
-             UA_BrowseResponse *response) {
-    printf ("%-50s%i\n", "Received BrowseResponse for request ", requestId);
+fileBrowsed(UA_Client *client, void *userdata, UA_UInt32 requestId,
+            UA_BrowseResponse *response) {
+    printf("%-50s%i\n", "Received BrowseResponse for request ", requestId);
     UA_String us = *(UA_String *) userdata;
-    printf ("---%.*s passed safely \n", (int) us.length, us.data);
+    printf("---%.*s passed safely \n", (int) us.length, us.data);
 }
 
 /*high-level function callbacks*/
 static
 void
-readValueAttributeCallback (UA_Client *client, void *userdata,
-                            UA_UInt32 requestId, UA_Variant *var) {
-    printf ("%-50s%i\n", "Read value attribute for request", requestId);
+readValueAttributeCallback(UA_Client *client, void *userdata,
+                           UA_UInt32 requestId, UA_Variant *var) {
+    printf("%-50s%i\n", "Read value attribute for request", requestId);
 
-    if (UA_Variant_hasScalarType (var, &UA_TYPES[UA_TYPES_INT32])) {
+    if(UA_Variant_hasScalarType(var, &UA_TYPES[UA_TYPES_INT32])) {
         UA_Int32 int_val = *(UA_Int32*) var->data;
-        printf ("---%-40s%-8i\n",
-                "Reading the value of node (1, \"the.answer\"):", int_val);
+        printf("---%-40s%-8i\n",
+               "Reading the value of node (1, \"the.answer\"):", int_val);
     }
 
     /*more type distinctions possible*/
@@ -53,11 +53,11 @@ readValueAttributeCallback (UA_Client *client, void *userdata,
 
 static
 void
-attrWritten (UA_Client *client, void *userdata, UA_UInt32 requestId,
-             UA_WriteResponse *response) {
+attrWritten(UA_Client *client, void *userdata, UA_UInt32 requestId,
+            UA_WriteResponse *response) {
     /*assuming no data to be retrieved by writing attributes*/
-    printf ("%-50s%i\n", "Wrote value attribute for request ", requestId);
-    UA_WriteResponse_deleteMembers(response);
+    printf("%-50s%i\n", "Wrote value attribute for request ", requestId);
+    UA_WriteResponse_clear(response);
 }
 
 #ifdef NODES_EXIST
@@ -66,18 +66,18 @@ static void
 methodCalled(UA_Client *client, void *userdata, UA_UInt32 requestId,
              UA_CallResponse *response) {
 
-    printf ("%-50s%i\n", "Called method for request ", requestId);
+    printf("%-50s%i\n", "Called method for request ", requestId);
     size_t outputSize;
     UA_Variant *output;
     UA_StatusCode retval = response->responseHeader.serviceResult;
-    if (retval == UA_STATUSCODE_GOOD) {
-        if (response->resultsSize == 1)
+    if(retval == UA_STATUSCODE_GOOD) {
+        if(response->resultsSize == 1)
             retval = response->results[0].statusCode;
         else
             retval = UA_STATUSCODE_BADUNEXPECTEDERROR;
     }
-    if (retval != UA_STATUSCODE_GOOD) {
-        UA_CallResponse_deleteMembers (response);
+    if(retval != UA_STATUSCODE_GOOD) {
+        UA_CallResponse_clear(response);
     }
 
     /* Move the output arguments */
@@ -86,74 +86,67 @@ methodCalled(UA_Client *client, void *userdata, UA_UInt32 requestId,
     response->results[0].outputArguments = NULL;
     response->results[0].outputArgumentsSize = 0;
 
-    if (retval == UA_STATUSCODE_GOOD) {
-        printf ("---Method call was successful, returned %lu values.\n",
-                (unsigned long) outputSize);
-        UA_Array_delete (output, outputSize, &UA_TYPES[UA_TYPES_VARIANT]);
-    }
-    else {
-        printf ("---Method call was unsuccessful, returned %x values.\n",
+    if(retval == UA_STATUSCODE_GOOD) {
+        printf("---Method call was successful, returned %lu values.\n",
+               (unsigned long) outputSize);
+        UA_Array_delete(output, outputSize, &UA_TYPES[UA_TYPES_VARIANT]);
+    } else {
+        printf("---Method call was unsuccessful, returned %x values.\n",
                 retval);
     }
-    UA_CallResponse_deleteMembers (response);
+    UA_CallResponse_clear(response);
 }
 
 static void
-translateCalled (UA_Client *client, void *userdata, UA_UInt32 requestId,
-                 UA_TranslateBrowsePathsToNodeIdsResponse *response) {
-    printf ("%-50s%i\n", "Translated path for request ", requestId);
+translateCalled(UA_Client *client, void *userdata, UA_UInt32 requestId,
+                UA_TranslateBrowsePathsToNodeIdsResponse *response) {
+    printf("%-50s%i\n", "Translated path for request ", requestId);
 
-    if (response->results[0].targetsSize == 1) {
+    if(response->results[0].targetsSize == 1)
         return;
-    }
-    UA_TranslateBrowsePathsToNodeIdsResponse_deleteMembers (response);
+    UA_TranslateBrowsePathsToNodeIdsResponse_clear(response);
 }
 #endif /* UA_ENABLE_METHODCALLS */
 #endif
 
 int
-main (int argc, char *argv[]) {
-    UA_Client *client = UA_Client_new (UA_ClientConfig_default);
+main(int argc, char *argv[]) {
+    UA_Client *client = UA_Client_new(UA_ClientConfig_default);
     UA_UInt32 reqId = 0;
-    UA_String userdata = UA_STRING ("userdata");
+    UA_String userdata = UA_STRING("userdata");
 
     UA_BrowseRequest bReq;
-    UA_BrowseRequest_init (&bReq);
+    UA_BrowseRequest_init(&bReq);
     bReq.requestedMaxReferencesPerNode = 0;
-    bReq.nodesToBrowse = UA_BrowseDescription_new ();
+    bReq.nodesToBrowse = UA_BrowseDescription_new();
     bReq.nodesToBrowseSize = 1;
-    bReq.nodesToBrowse[0].nodeId = UA_NODEID_NUMERIC (0,
-    UA_NS0ID_OBJECTSFOLDER); /* browse objects folder */
+    bReq.nodesToBrowse[0].nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
     bReq.nodesToBrowse[0].resultMask = UA_BROWSERESULTMASK_ALL; /* return everything */
 
-    UA_Client_connect_async (client, "opc.tcp://localhost:4840", onConnect,
-                             NULL);
+    UA_Client_connect_async(client, "opc.tcp://localhost:4840", onConnect, NULL);
 
     /*Windows needs time to response*/
     UA_sleep_ms(100);
 
     /* What happens if client tries to send request before connected? */
-    UA_Client_sendAsyncBrowseRequest (client, &bReq, fileBrowsed, &userdata,
-                                      &reqId);
+    UA_Client_sendAsyncBrowseRequest(client, &bReq, fileBrowsed, &userdata, &reqId);
 
     UA_DateTime startTime = UA_DateTime_nowMonotonic();
     do {
         /*TODO: fix memory-related bugs if condition not checked*/
-        if (UA_Client_getState (client) == UA_CLIENTSTATE_SESSION) {
+        if(UA_Client_getState(client) == UA_CLIENTSTATE_SESSION) {
             /* If not connected requests are not sent */
-            UA_Client_sendAsyncBrowseRequest (client, &bReq, fileBrowsed,
-                                              &userdata, &reqId);
+            UA_Client_sendAsyncBrowseRequest(client, &bReq, fileBrowsed, &userdata, &reqId);
         }
         /* Requests are processed */
-        UA_BrowseRequest_deleteMembers(&bReq);
-        UA_Client_run_iterate (client, 0);
+        UA_BrowseRequest_clear(&bReq);
+        UA_Client_run_iterate(client, 0);
         UA_sleep_ms(100);
 
         /* Break loop if server cannot be connected within 2s -- prevents build timeout */
-        if (UA_DateTime_nowMonotonic() - startTime > 2000 * UA_DATETIME_MSEC)
+        if(UA_DateTime_nowMonotonic() - startTime > 2000 * UA_DATETIME_MSEC)
             break;
-    }
-    while (reqId < 10);
+    } while(reqId < 10);
 
     /* Demo: high-level functions */
     UA_Int32 value = 0;
@@ -161,45 +154,43 @@ main (int argc, char *argv[]) {
     UA_Variant_init(&myVariant);
 
     UA_Variant input;
-    UA_Variant_init (&input);
+    UA_Variant_init(&input);
 
-    for (UA_UInt16 i = 0; i < 5; i++) {
-        if (UA_Client_getState (client) == UA_CLIENTSTATE_SESSION) {
+    for(UA_UInt16 i = 0; i < 5; i++) {
+        if(UA_Client_getState(client) == UA_CLIENTSTATE_SESSION) {
             /* writing and reading value 1 to 5 */
-            UA_Variant_setScalarCopy (&myVariant, &value, &UA_TYPES[UA_TYPES_INT32]);
+            UA_Variant_setScalarCopy(&myVariant, &value, &UA_TYPES[UA_TYPES_INT32]);
             value++;
             UA_Client_writeValueAttribute_async(client,
-                                                UA_NODEID_STRING (1, "the.answer"),
+                                                UA_NODEID_STRING(1, "the.answer"),
                                                 &myVariant, attrWritten, NULL,
                                                 &reqId);
-            UA_Variant_deleteMembers (&myVariant);
+            UA_Variant_clear(&myVariant);
 
             UA_Client_readValueAttribute_async(client,
-                                               UA_NODEID_STRING (1, "the.answer"),
+                                               UA_NODEID_STRING(1, "the.answer"),
                                                readValueAttributeCallback, NULL,
                                                &reqId);
 
 //TODO: check the existance of the nodes inside these functions (otherwise seg faults)
 #ifdef NODES_EXIST
 #ifdef UA_ENABLE_METHODCALLS
-            UA_String stringValue = UA_String_fromChars ("World");
-            UA_Variant_setScalar (&input, &stringValue, &UA_TYPES[UA_TYPES_STRING]);
+            UA_String stringValue = UA_String_fromChars("World");
+            UA_Variant_setScalar(&input, &stringValue, &UA_TYPES[UA_TYPES_STRING]);
 
             UA_Client_call_async(client,
-                                 UA_NODEID_NUMERIC (0, UA_NS0ID_OBJECTSFOLDER),
-                                 UA_NODEID_NUMERIC (1, 62541), 1, &input,
+                                 UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
+                                 UA_NODEID_NUMERIC(1, 62541), 1, &input,
                                  methodCalled, NULL, &reqId);
-            UA_String_deleteMembers(&stringValue);
+            UA_String_clear(&stringValue);
 
     #define pathSize 3
             char *paths[pathSize] = { "Server", "ServerStatus", "State" };
             UA_UInt32 ids[pathSize] = { UA_NS0ID_ORGANIZES,
             UA_NS0ID_HASCOMPONENT, UA_NS0ID_HASCOMPONENT };
 
-            UA_Cient_translateBrowsePathsToNodeIds_async (client, paths, ids,
-                                                          pathSize,
-                                                          translateCalled, NULL,
-                                                          &reqId);
+            UA_Cient_translateBrowsePathsToNodeIds_async(client, paths, ids, pathSize,
+                                                         translateCalled, NULL, &reqId);
 #endif /* UA_ENABLE_METHODCALLS */
 #endif
             /* How often UA_Client_run_iterate is called depends on the number of request sent */
@@ -207,13 +198,13 @@ main (int argc, char *argv[]) {
             UA_Client_run_iterate(client, 0);
         }
     }
-    UA_Client_run_iterate (client, 0);
+    UA_Client_run_iterate(client, 0);
 
     /* Async disconnect kills unprocessed requests */
     // UA_Client_disconnect_async (client, &reqId); //can only be used when connected = true
     // UA_Client_run_iterate (client, &timedOut);
     UA_Client_disconnect(client);
-    UA_Client_delete (client);
+    UA_Client_delete(client);
 
     return (int) UA_STATUSCODE_GOOD;
 }

+ 2 - 2
examples/client_connect_loop.c

@@ -65,12 +65,12 @@ int main(void) {
                         "date is: %02u-%02u-%04u %02u:%02u:%02u.%03u",
                         dts.day, dts.month, dts.year, dts.hour, dts.min, dts.sec, dts.milliSec);
         }
-        UA_Variant_deleteMembers(&value);
+        UA_Variant_clear(&value);
         UA_sleep_ms(1000);
     };
 
     /* Clean up */
-    UA_Variant_deleteMembers(&value);
+    UA_Variant_clear(&value);
     UA_Client_delete(client); /* Disconnects the client internally */
     return UA_STATUSCODE_GOOD;
 }

+ 1 - 1
examples/common.h

@@ -26,7 +26,7 @@ loadFile(const char *const path) {
         fseek(fp, 0, SEEK_SET);
         size_t read = fread(fileContents.data, sizeof(UA_Byte), fileContents.length, fp);
         if(read != fileContents.length)
-            UA_ByteString_deleteMembers(&fileContents);
+            UA_ByteString_clear(&fileContents);
     } else {
         fileContents.length = 0;
     }

+ 1 - 1
examples/custom_datatype/client_types_custom.c

@@ -37,7 +37,7 @@ int main(void) {
     }
 
     /* Clean up */
-    UA_Variant_deleteMembers(&value);
+    UA_Variant_clear(&value);
     UA_Client_delete(client); /* Disconnects the client internally */
     return UA_STATUSCODE_GOOD;
 }

+ 1 - 1
examples/discovery/server_lds.c

@@ -20,7 +20,7 @@ int main(void) {
 
     UA_ServerConfig *config = UA_ServerConfig_new_default();
     config->applicationDescription.applicationType = UA_APPLICATIONTYPE_DISCOVERYSERVER;
-    UA_String_deleteMembers(&config->applicationDescription.applicationUri);
+    UA_String_clear(&config->applicationDescription.applicationUri);
     config->applicationDescription.applicationUri =
             UA_String_fromChars("urn:open62541.example.local_discovery_server");
     config->mdnsServerName = UA_String_fromChars("LDS");

+ 7 - 7
examples/discovery/server_multicast.c

@@ -164,7 +164,7 @@ static UA_ByteString loadFile(const char *const path) {
         fseek(fp, 0, SEEK_SET);
         size_t read = fread(fileContents.data, sizeof(UA_Byte), fileContents.length, fp);
         if (read != fileContents.length)
-            UA_ByteString_deleteMembers(&fileContents);
+            UA_ByteString_clear(&fileContents);
     } else {
         fileContents.length = 0;
     }
@@ -226,8 +226,8 @@ UA_Client *getRegisterClient(UA_EndpointDescription *endpointRegister, int argc,
         trustListSize = (size_t) argc - 3;
         UA_StatusCode retval = UA_ByteString_allocBuffer(trustList, trustListSize);
         if (retval != UA_STATUSCODE_GOOD) {
-            UA_ByteString_deleteMembers(&certificate);
-            UA_ByteString_deleteMembers(&privateKey);
+            UA_ByteString_clear(&certificate);
+            UA_ByteString_clear(&privateKey);
             return NULL;
         }
 
@@ -244,10 +244,10 @@ UA_Client *getRegisterClient(UA_EndpointDescription *endpointRegister, int argc,
                                           trustList, trustListSize,
                                           revocationList, revocationListSize,
                                           UA_SecurityPolicy_Basic128Rsa15);
-    UA_ByteString_deleteMembers(&certificate);
-    UA_ByteString_deleteMembers(&privateKey);
+    UA_ByteString_clear(&certificate);
+    UA_ByteString_clear(&privateKey);
     for (size_t deleteCount = 0; deleteCount < trustListSize; deleteCount++) {
-        UA_ByteString_deleteMembers(&trustList[deleteCount]);
+        UA_ByteString_clear(&trustList[deleteCount]);
     }
 
     return clientRegister;
@@ -263,7 +263,7 @@ int main(int argc, char **argv) {
     UA_ServerConfig *config = UA_ServerConfig_new_minimal(16600, NULL);
     // To enable mDNS discovery, set application type to discovery server.
     config->applicationDescription.applicationType = UA_APPLICATIONTYPE_DISCOVERYSERVER;
-    UA_String_deleteMembers(&config->applicationDescription.applicationUri);
+    UA_String_clear(&config->applicationDescription.applicationUri);
     config->applicationDescription.applicationUri =
         UA_String_fromChars("urn:open62541.example.server_multicast");
     config->mdnsServerName = UA_String_fromChars("Sample Multicast Server");

+ 1 - 1
examples/discovery/server_register.c

@@ -60,7 +60,7 @@ int main(int argc, char **argv) {
     signal(SIGTERM, stopHandler);
 
     UA_ServerConfig *config = UA_ServerConfig_new_default();
-    UA_String_deleteMembers(&config->applicationDescription.applicationUri);
+    UA_String_clear(&config->applicationDescription.applicationUri);
     config->applicationDescription.applicationUri =
         UA_String_fromChars("urn:open62541.example.server_register");
     config->mdnsServerName = UA_String_fromChars("Sample Server");

+ 4 - 4
examples/encryption/client_basic128rsa15.c

@@ -115,10 +115,10 @@ int main(int argc, char* argv[]) {
         return FAILURE;
     }
 
-    UA_ByteString_deleteMembers(&certificate);
-    UA_ByteString_deleteMembers(&privateKey);
+    UA_ByteString_clear(&certificate);
+    UA_ByteString_clear(&privateKey);
     for(size_t deleteCount = 0; deleteCount < trustListSize; deleteCount++) {
-        UA_ByteString_deleteMembers(&trustList[deleteCount]);
+        UA_ByteString_clear(&trustList[deleteCount]);
     }
 
     /* Secure client connect */
@@ -144,7 +144,7 @@ int main(int argc, char* argv[]) {
     }
 
     /* Clean up */
-    UA_Variant_deleteMembers(&value);
+    UA_Variant_clear(&value);
     cleanupClient(client, remoteCertificate);
     return (int)retval;
 }

+ 4 - 4
examples/encryption/client_basic256sha256.c

@@ -115,10 +115,10 @@ int main(int argc, char* argv[]) {
         return FAILURE;
     }
 
-    UA_ByteString_deleteMembers(&certificate);
-    UA_ByteString_deleteMembers(&privateKey);
+    UA_ByteString_clear(&certificate);
+    UA_ByteString_clear(&privateKey);
     for(size_t deleteCount = 0; deleteCount < trustListSize; deleteCount++) {
-        UA_ByteString_deleteMembers(&trustList[deleteCount]);
+        UA_ByteString_clear(&trustList[deleteCount]);
     }
 
     /* Secure client connect */
@@ -144,7 +144,7 @@ int main(int argc, char* argv[]) {
     }
 
     /* Clean up */
-    UA_Variant_deleteMembers(&value);
+    UA_Variant_clear(&value);
     cleanupClient(client, remoteCertificate);
     return (int)retval;
 }

+ 3 - 3
examples/encryption/server_basic128rsa15.c

@@ -43,10 +43,10 @@ int main(int argc, char* argv[]) {
         UA_ServerConfig_new_basic128rsa15(4840, &certificate, &privateKey,
                                           trustList, trustListSize,
                                           revocationList, revocationListSize);
-    UA_ByteString_deleteMembers(&certificate);
-    UA_ByteString_deleteMembers(&privateKey);
+    UA_ByteString_clear(&certificate);
+    UA_ByteString_clear(&privateKey);
     for(size_t i = 0; i < trustListSize; i++)
-        UA_ByteString_deleteMembers(&trustList[i]);
+        UA_ByteString_clear(&trustList[i]);
 
     if(!config) {
         UA_LOG_FATAL(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,

+ 3 - 3
examples/encryption/server_basic256sha256.c

@@ -43,10 +43,10 @@ int main(int argc, char* argv[]) {
         UA_ServerConfig_new_basic256sha256(4840, &certificate, &privateKey,
                                           trustList, trustListSize,
                                           revocationList, revocationListSize);
-    UA_ByteString_deleteMembers(&certificate);
-    UA_ByteString_deleteMembers(&privateKey);
+    UA_ByteString_clear(&certificate);
+    UA_ByteString_clear(&privateKey);
     for(size_t i = 0; i < trustListSize; i++)
-        UA_ByteString_deleteMembers(&trustList[i]);
+        UA_ByteString_clear(&trustList[i]);
 
     if(!config) {
         UA_LOG_FATAL(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,

+ 3 - 3
examples/pubsub/tutorial_pubsub_subscribe.c

@@ -47,7 +47,7 @@ subscriptionPollingCallback(UA_Server *server, UA_PubSubConnection *connection)
          * TODO: Return an error code in 'receive' instead of setting the buf
          * length to zero. */
         buffer.length = 512;
-        UA_ByteString_deleteMembers(&buffer);
+        UA_ByteString_clear(&buffer);
         return;
     }
 
@@ -58,7 +58,7 @@ subscriptionPollingCallback(UA_Server *server, UA_PubSubConnection *connection)
     memset(&networkMessage, 0, sizeof(UA_NetworkMessage));
     size_t currentPosition = 0;
     UA_NetworkMessage_decodeBinary(&buffer, &currentPosition, &networkMessage);
-    UA_ByteString_deleteMembers(&buffer);
+    UA_ByteString_clear(&buffer);
 
     /* Is this the correct message type? */
     if(networkMessage.networkMessageType != UA_NETWORKMESSAGE_DATASET)
@@ -93,7 +93,7 @@ subscriptionPollingCallback(UA_Server *server, UA_PubSubConnection *connection)
     }
 
  cleanup:
-    UA_NetworkMessage_deleteMembers(&networkMessage);
+    UA_NetworkMessage_clear(&networkMessage);
 }
 
 static int

+ 3 - 3
examples/server.cpp

@@ -39,9 +39,9 @@ int main() {
                               UA_NODEID_NULL, attr, NULL, NULL);
 
     /* allocations on the heap need to be freed */
-    UA_VariableAttributes_deleteMembers(&attr);
-    UA_NodeId_deleteMembers(&myIntegerNodeId);
-    UA_QualifiedName_deleteMembers(&myIntegerName);
+    UA_VariableAttributes_clear(&attr);
+    UA_NodeId_clear(&myIntegerNodeId);
+    UA_QualifiedName_clear(&myIntegerName);
 
     UA_StatusCode retval = UA_Server_run(server, &running);
     UA_Server_delete(server);

+ 1 - 1
examples/server_certificate.c

@@ -31,7 +31,7 @@ int main(int argc, char** argv) {
     UA_StatusCode retval = UA_Server_run(server, &running);
 
     /* deallocate certificate's memory */
-    UA_ByteString_deleteMembers(&config->serverCertificate);
+    UA_ByteString_clear(&config->serverCertificate);
 
     UA_Server_delete(server);
     UA_ServerConfig_delete(config);

+ 10 - 10
examples/server_ctt.c

@@ -67,7 +67,7 @@ helloWorld(UA_Server *server,
     memcpy(greet.data, hello.data, hello.length);
     memcpy(greet.data + hello.length, name->data, name->length);
     UA_Variant_setScalarCopy(output, &greet, &UA_TYPES[UA_TYPES_STRING]);
-    UA_String_deleteMembers(&greet);
+    UA_String_clear(&greet);
     return UA_STATUSCODE_GOOD;
 }
 
@@ -264,7 +264,7 @@ setInformationModel(UA_Server *server) {
         UA_Server_addVariableNode(server, UA_NODEID_NUMERIC(1, ++id),
                                   UA_NODEID_NUMERIC(1, SCALARID), UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
                                   qualifiedName, baseDataVariableType, attr, NULL, NULL);
-        UA_Variant_deleteMembers(&attr.value);
+        UA_Variant_clear(&attr.value);
 
         /* add an array node for every built-in type */
         UA_UInt32 arrayDims = 0;
@@ -275,7 +275,7 @@ setInformationModel(UA_Server *server) {
         UA_Server_addVariableNode(server, UA_NODEID_NUMERIC(1, ++id), UA_NODEID_NUMERIC(1, ARRAYID),
                                   UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES), qualifiedName,
                                   baseDataVariableType, attr, NULL, NULL);
-        UA_Variant_deleteMembers(&attr.value);
+        UA_Variant_clear(&attr.value);
 
         /* add an matrix node for every built-in type */
         attr.valueRank = UA_VALUERANK_TWO_DIMENSIONS;
@@ -292,10 +292,10 @@ setInformationModel(UA_Server *server) {
         UA_Server_addVariableNode(server, UA_NODEID_NUMERIC(1, ++id), UA_NODEID_NUMERIC(1, MATRIXID),
                                   UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES), qualifiedName,
                                   baseDataVariableType, attr, NULL, NULL);
-        UA_Variant_deleteMembers(&attr.value);
+        UA_Variant_clear(&attr.value);
 #ifdef UA_ENABLE_TYPENAMES
-        UA_LocalizedText_deleteMembers(&attr.displayName);
-        UA_QualifiedName_deleteMembers(&qualifiedName);
+        UA_LocalizedText_clear(&attr.displayName);
+        UA_QualifiedName_clear(&qualifiedName);
 #endif
     }
 
@@ -453,10 +453,10 @@ int main(int argc, char **argv) {
         config = UA_ServerConfig_new_allSecurityPolicies(4840, &certificate, &privateKey,
                                                          trustList, trustListSize,
                                                          revocationList, revocationListSize);
-        UA_ByteString_deleteMembers(&certificate);
-        UA_ByteString_deleteMembers(&privateKey);
+        UA_ByteString_clear(&certificate);
+        UA_ByteString_clear(&privateKey);
         for(size_t i = 0; i < trustListSize; i++)
-            UA_ByteString_deleteMembers(&trustList[i]);
+            UA_ByteString_clear(&trustList[i]);
     }
 #else
     UA_ByteString certificate = UA_BYTESTRING_NULL;
@@ -467,7 +467,7 @@ int main(int argc, char **argv) {
         certificate = loadFile(argv[1]);
     }
     config = UA_ServerConfig_new_minimal(4840, &certificate);
-    UA_ByteString_deleteMembers(&certificate);
+    UA_ByteString_clear(&certificate);
 #endif
 
     if(!config) {

+ 1 - 2
examples/tutorial_client_events.c

@@ -78,7 +78,6 @@ setupSelectClauses(void) {
     selectClauses[1].browsePath = (UA_QualifiedName*)
         UA_Array_new(selectClauses[1].browsePathSize, &UA_TYPES[UA_TYPES_QUALIFIEDNAME]);
     if(!selectClauses[1].browsePath) {
-        UA_SimpleAttributeOperand_deleteMembers(selectClauses);
         UA_SimpleAttributeOperand_delete(selectClauses);
         return NULL;
     }
@@ -161,7 +160,7 @@ int main(int argc, char *argv[]) {
 
     /* Delete the subscription */
  cleanup:
-    UA_MonitoredItemCreateResult_deleteMembers(&result);
+    UA_MonitoredItemCreateResult_clear(&result);
     UA_Client_Subscriptions_deleteSingle(client, response.subscriptionId);
     UA_Array_delete(filter.selectClauses, nSelectClauses, &UA_TYPES[UA_TYPES_SIMPLEATTRIBUTEOPERAND]);
 #endif

+ 1 - 1
examples/tutorial_client_firststeps.c

@@ -36,7 +36,7 @@ int main(void) {
     }
 
     /* Clean up */
-    UA_Variant_deleteMembers(&value);
+    UA_Variant_clear(&value);
     UA_Client_delete(client); /* Disconnects the client internally */
     return UA_STATUSCODE_GOOD;
 }

+ 7 - 7
examples/tutorial_datatypes.c

@@ -38,12 +38,12 @@ variables_basic(void) {
 
     UA_String s2;
     UA_String_copy(&s, &s2);
-    UA_String_deleteMembers(&s2); /* Copying heap-allocated the dynamic content */
+    UA_String_clear(&s2); /* Copying heap-allocated the dynamic content */
 
     UA_String s3 = UA_STRING("test2");
     UA_String s4 = UA_STRING_ALLOC("test2"); /* Copies the content to the heap */
     UA_Boolean eq = UA_String_equal(&s3, &s4);
-    UA_String_deleteMembers(&s4);
+    UA_String_clear(&s4);
     if(!eq)
         return;
 
@@ -59,7 +59,7 @@ variables_basic(void) {
 
     UA_ReadRequest *rr2 = UA_ReadRequest_new();
     UA_copy(&rr, rr2, &UA_TYPES[UA_TYPES_READREQUEST]);
-    UA_ReadRequest_deleteMembers(&rr);
+    UA_ReadRequest_clear(&rr);
     UA_ReadRequest_delete(rr2);
 }
 
@@ -83,11 +83,11 @@ variables_nodeids(void) {
 
     UA_NodeId id3;
     UA_NodeId_copy(&id2, &id3);
-    UA_NodeId_deleteMembers(&id3);
+    UA_NodeId_clear(&id3);
 
     UA_NodeId id4 = UA_NODEID_STRING_ALLOC(1, "testid"); /* the string is copied
                                                             to the heap */
-    UA_NodeId_deleteMembers(&id4);
+    UA_NodeId_clear(&id4);
 }
 
 /**
@@ -109,7 +109,7 @@ variables_variants(void) {
     /* Make a copy */
     UA_Variant v2;
     UA_Variant_copy(&v, &v2);
-    UA_Variant_deleteMembers(&v2);
+    UA_Variant_clear(&v2);
 
     /* Set an array value */
     UA_Variant v3;
@@ -123,7 +123,7 @@ variables_variants(void) {
     v3.arrayDimensionsSize = 2;
     v3.arrayDimensions[0] = 3;
     v3.arrayDimensions[1] = 3;
-    UA_Variant_deleteMembers(&v3);
+    UA_Variant_clear(&v3);
 }
 
 /** It follows the main function, making use of the above definitions. */

+ 1 - 1
examples/tutorial_server_method.c

@@ -48,7 +48,7 @@ helloWorldMethodCallback(UA_Server *server,
         tmp.length += inputStr->length;
     }
     UA_Variant_setScalarCopy(output, &tmp, &UA_TYPES[UA_TYPES_STRING]);
-    UA_String_deleteMembers(&tmp);
+    UA_String_clear(&tmp);
     UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "Hello World was called");
     return UA_STATUSCODE_GOOD;
 }

+ 1 - 1
examples/tutorial_server_object.c

@@ -288,7 +288,7 @@ pumpTypeConstructor(UA_Server *server,
     UA_Variant value;
     UA_Variant_setScalar(&value, &status, &UA_TYPES[UA_TYPES_BOOLEAN]);
     UA_Server_writeValue(server, bpr.targets[0].targetId.nodeId, value);
-    UA_BrowsePathResult_deleteMembers(&bpr);
+    UA_BrowsePathResult_clear(&bpr);
 
     /* At this point we could replace the node context .. */
 

+ 2 - 0
src/pubsub/ua_pubsub_networkmessage.h

@@ -212,6 +212,8 @@ UA_NetworkMessage_calcSizeBinary(const UA_NetworkMessage* p);
 void
 UA_NetworkMessage_deleteMembers(UA_NetworkMessage* p);
 
+#define UA_NetworkMessage_clear(p) UA_NetworkMessage_deleteMembers(p)
+
 void
 UA_NetworkMessage_delete(UA_NetworkMessage* p);