瀏覽代碼

use only UA_malloc internally

Julius Pfrommer 8 年之前
父節點
當前提交
93866c3b6e
共有 1 個文件被更改,包括 9 次插入9 次删除
  1. 9 9
      src/server/ua_mdns.c

+ 9 - 9
src/server/ua_mdns.c

@@ -28,7 +28,7 @@
 #ifndef STRDUP
 # if defined(__MINGW32__)
 static char *ua_strdup(const char *s) {
-    char *p = malloc(strlen(s) + 1);
+    char *p = UA_malloc(strlen(s) + 1);
     if(p) { strcpy(p, s); }
     return p;
 }
@@ -83,7 +83,7 @@ mdns_record_add_or_get(UA_Server *server, const char *record, const char *server
     // not yet in list, create new one
     // todo: malloc may fail: return a statuscode
     struct serverOnNetwork_list_entry *listEntry =
-            (serverOnNetwork_list_entry *) malloc(sizeof(struct serverOnNetwork_list_entry));
+            (serverOnNetwork_list_entry*)UA_malloc(sizeof(struct serverOnNetwork_list_entry));
     listEntry->created = UA_DateTime_now();
     listEntry->pathTmp = NULL;
     listEntry->txtSet = UA_FALSE;
@@ -92,7 +92,7 @@ mdns_record_add_or_get(UA_Server *server, const char *record, const char *server
     listEntry->serverOnNetwork.recordId = server->serverOnNetworkRecordIdCounter;
     listEntry->serverOnNetwork.serverName.length = serverNameLen;
     // todo: malloc may fail: return a statuscode
-    listEntry->serverOnNetwork.serverName.data = (UA_Byte *) malloc(serverNameLen);
+    listEntry->serverOnNetwork.serverName.data = (UA_Byte*)UA_malloc(serverNameLen);
     memcpy(listEntry->serverOnNetwork.serverName.data, serverName, serverNameLen);
     server->serverOnNetworkRecordIdCounter = UA_atomic_add(&server->serverOnNetworkRecordIdCounter, 1);
     if (server->serverOnNetworkRecordIdCounter == 0)
@@ -101,7 +101,7 @@ mdns_record_add_or_get(UA_Server *server, const char *record, const char *server
     // add to hash
     // todo: malloc may fail: return a statuscode
     struct serverOnNetwork_hash_entry *newHashEntry =
-            (struct serverOnNetwork_hash_entry *) malloc(sizeof(struct serverOnNetwork_hash_entry));
+            (struct serverOnNetwork_hash_entry*)UA_malloc(sizeof(struct serverOnNetwork_hash_entry));
     newHashEntry->next = server->serverOnNetworkHash[hashIdx];
     server->serverOnNetworkHash[hashIdx] = newHashEntry;
     newHashEntry->entry = listEntry;
@@ -154,7 +154,7 @@ static void
 mdns_append_path_to_url(UA_String *url, const char *path) {
     size_t pathLen = strlen(path);
     // todo: malloc may fail: return a statuscode
-    char *newUrl = (char *) malloc(url->length + pathLen);
+    char *newUrl = (char *)UA_malloc(url->length + pathLen);
     memcpy(newUrl, url->data, url->length);
     memcpy(newUrl + url->length, path, pathLen);
     url->length = url->length + pathLen;
@@ -198,7 +198,7 @@ setTxt(const struct resource *r,
             size_t len = nextStr ? (size_t) (nextStr - caps) : strlen(caps);
             entry->serverOnNetwork.serverCapabilities[i].length = len;
             // todo: malloc may fail: return a statuscode
-            entry->serverOnNetwork.serverCapabilities[i].data = (UA_Byte *) malloc(len);
+            entry->serverOnNetwork.serverCapabilities[i].data = (UA_Byte*)UA_malloc(len);
             memcpy(entry->serverOnNetwork.serverCapabilities[i].data, caps, len);
             if (nextStr)
                 caps = nextStr + 1;
@@ -221,7 +221,7 @@ setSrv(UA_Server *server, const struct resource *r,
         srvNameLen--;
 
     // todo: malloc may fail: return a statuscode
-    char *newUrl = (char *) malloc(10 + srvNameLen + 8);
+    char *newUrl = (char*)UA_malloc(10 + srvNameLen + 8);
     sprintf(newUrl, "opc.tcp://%.*s:%d", (int) srvNameLen,
             r->known.srv.name, r->known.srv.port);
     UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_SERVER,
@@ -307,7 +307,7 @@ void mdns_create_txt(UA_Server *server, const char *fullServiceDomain, const cha
             allocPath = STRDUP(path);
         else {
             // todo: malloc may fail: return a statuscode
-            allocPath = (char *) malloc(strlen(path) + 2);
+            allocPath = (char*)UA_malloc(strlen(path) + 2);
             allocPath[0] = '/';
             memcpy(allocPath + 1, path, strlen(path));
             allocPath[strlen(path) + 1] = '\0';
@@ -326,7 +326,7 @@ void mdns_create_txt(UA_Server *server, const char *fullServiceDomain, const cha
     if(capsLen) {
         // freed when xht_free is called
         // todo: malloc may fail: return a statuscode
-        caps = (char *) malloc(sizeof(char) * capsLen);
+        caps = (char*)UA_malloc(sizeof(char) * capsLen);
         size_t idx = 0;
         for (size_t i = 0; i < *capabilitiesSize; i++) {
             strncpy(caps + idx, (const char *) capabilites[i].data, capabilites[i].length);