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