|
@@ -21,6 +21,9 @@ extern "C" {
|
|
|
#endif
|
|
|
|
|
|
#include <stdint.h>
|
|
|
+#include <string.h>
|
|
|
+#include <stdlib.h>
|
|
|
+#include <inttypes.h>
|
|
|
#include <stdbool.h>
|
|
|
#include "ua_config.h"
|
|
|
#include "ua_constants.h"
|
|
@@ -216,9 +219,11 @@ UA_EXPORT extern const UA_String UA_STRING_NULL;
|
|
|
* ``UA_STRING_ALLOC`` is shorthand for ``UA_String_fromChars`` and makes a copy
|
|
|
* of the char-array. */
|
|
|
static UA_INLINE UA_String
|
|
|
-UA_STRING(char *chars) {
|
|
|
+UA_STRING(const char *chars) {
|
|
|
UA_String str; str.length = strlen(chars);
|
|
|
- str.data = (UA_Byte*)chars; return str;
|
|
|
+ str.length = strlen(chars);
|
|
|
+ str.data = (UA_Byte *) malloc(str.length ); memcpy(str.data, chars, str.length );
|
|
|
+ return str;
|
|
|
}
|
|
|
|
|
|
#define UA_STRING_ALLOC(CHARS) UA_String_fromChars(CHARS)
|
|
@@ -290,7 +295,7 @@ UA_StatusCode UA_EXPORT UA_ByteString_allocBuffer(UA_ByteString *bs, size_t leng
|
|
|
UA_EXPORT extern const UA_ByteString UA_BYTESTRING_NULL;
|
|
|
|
|
|
static UA_INLINE UA_ByteString
|
|
|
-UA_BYTESTRING(char *chars) {
|
|
|
+UA_BYTESTRING( char *chars) {
|
|
|
UA_ByteString str; str.length = strlen(chars);
|
|
|
str.data = (UA_Byte*)chars; return str;
|
|
|
}
|
|
@@ -420,7 +425,7 @@ UA_EXPANDEDNODEID_STRING_GUID(UA_UInt16 nsIndex, UA_Guid guid) {
|
|
|
}
|
|
|
|
|
|
static UA_INLINE UA_ExpandedNodeId
|
|
|
-UA_EXPANDEDNODEID_BYTESTRING(UA_UInt16 nsIndex, char *chars) {
|
|
|
+UA_EXPANDEDNODEID_BYTESTRING(UA_UInt16 nsIndex, char *chars) {
|
|
|
UA_ExpandedNodeId id; id.nodeId = UA_NODEID_BYTESTRING(nsIndex, chars);
|
|
|
id.serverIndex = 0; id.namespaceUri = UA_STRING_NULL; return id;
|
|
|
}
|
|
@@ -441,9 +446,10 @@ typedef struct {
|
|
|
} UA_QualifiedName;
|
|
|
|
|
|
static UA_INLINE UA_QualifiedName
|
|
|
-UA_QUALIFIEDNAME(UA_UInt16 nsIndex, char *chars) {
|
|
|
+UA_QUALIFIEDNAME(UA_UInt16 nsIndex, const char *chars) {
|
|
|
UA_QualifiedName qn; qn.namespaceIndex = nsIndex;
|
|
|
- qn.name = UA_STRING(chars); return qn;
|
|
|
+ qn.name.length = strlen(chars);
|
|
|
+ qn.name.data = (UA_Byte *) malloc(qn.name.length ); memcpy(qn.name.data, chars, qn.name.length ); return qn;
|
|
|
}
|
|
|
|
|
|
static UA_INLINE UA_QualifiedName
|
|
@@ -462,7 +468,7 @@ typedef struct {
|
|
|
} UA_LocalizedText;
|
|
|
|
|
|
static UA_INLINE UA_LocalizedText
|
|
|
-UA_LOCALIZEDTEXT(char *locale, char *text) {
|
|
|
+UA_LOCALIZEDTEXT( const char *locale, const char *text) {
|
|
|
UA_LocalizedText lt; lt.locale = UA_STRING(locale);
|
|
|
lt.text = UA_STRING(text); return lt;
|
|
|
}
|