|
@@ -155,7 +155,7 @@ typedef struct {
|
|
} UA_String;
|
|
} UA_String;
|
|
|
|
|
|
/* Copies the content on the heap. Returns a null-string when alloc fails */
|
|
/* Copies the content on the heap. Returns a null-string when alloc fails */
|
|
-UA_String UA_EXPORT UA_String_fromChars(char const src[]) UA_FUNC_ATTR_WARN_UNUSED_RESULT;
|
|
|
|
|
|
+UA_String UA_EXPORT UA_String_fromChars(const char *src) UA_FUNC_ATTR_WARN_UNUSED_RESULT;
|
|
|
|
|
|
UA_Boolean UA_EXPORT UA_String_equal(const UA_String *s1, const UA_String *s2);
|
|
UA_Boolean UA_EXPORT UA_String_equal(const UA_String *s1, const UA_String *s2);
|
|
|
|
|
|
@@ -167,8 +167,10 @@ UA_EXPORT extern const UA_String UA_STRING_NULL;
|
|
* of the char-array. */
|
|
* of the char-array. */
|
|
static UA_INLINE UA_String
|
|
static UA_INLINE UA_String
|
|
UA_STRING(char *chars) {
|
|
UA_STRING(char *chars) {
|
|
- UA_String str; str.length = strlen(chars);
|
|
|
|
- str.data = (UA_Byte*)chars; return str;
|
|
|
|
|
|
+ UA_String s; s.length = 0; s.data = NULL;
|
|
|
|
+ if(!chars)
|
|
|
|
+ return s;
|
|
|
|
+ s.length = strlen(chars); s.data = (UA_Byte*)chars; return s;
|
|
}
|
|
}
|
|
|
|
|
|
#define UA_STRING_ALLOC(CHARS) UA_String_fromChars(CHARS)
|
|
#define UA_STRING_ALLOC(CHARS) UA_String_fromChars(CHARS)
|
|
@@ -275,8 +277,10 @@ UA_EXPORT extern const UA_ByteString UA_BYTESTRING_NULL;
|
|
|
|
|
|
static UA_INLINE UA_ByteString
|
|
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;
|
|
|
|
|
|
+ UA_ByteString bs; bs.length = 0; bs.data = NULL;
|
|
|
|
+ if(!chars)
|
|
|
|
+ return bs;
|
|
|
|
+ bs.length = strlen(chars); bs.data = (UA_Byte*)chars; return bs;
|
|
}
|
|
}
|
|
|
|
|
|
static UA_INLINE UA_ByteString
|
|
static UA_INLINE UA_ByteString
|