-enum bt_field_string_append_status bt_field_string_append(
- struct bt_field *field, const char *value)
-{
- BT_ASSERT_PRE_DEV_NO_ERROR();
-
- return bt_field_string_append_with_length(field,
- value, (uint64_t) strlen(value));
-}
-
-enum bt_field_string_append_status bt_field_string_append_with_length(
+#define BT_ASSERT_PRE_DEV_FOR_APPEND_TO_STRING_FIELD_WITH_LENGTH(_field, _value, _length) \
+ do { \
+ BT_ASSERT_PRE_DEV_NO_ERROR(); \
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(_field); \
+ BT_ASSERT_PRE_DEV_NON_NULL("value", (_value), "Value"); \
+ BT_ASSERT_PRE_DEV_FIELD_HOT(_field); \
+ BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field", \
+ (_field), "string-field", \
+ BT_FIELD_CLASS_TYPE_STRING, "Field"); \
+ BT_ASSERT_PRE_DEV("value-has-no-null-byte", \
+ !memchr((_value), '\0', (_length)), \
+ "String value to append contains a null character: " \
+ "partial-value=\"%.32s\", length=%" PRIu64, \
+ (_value), (_length)); \
+ } while (0)
+
+static
+enum bt_field_string_append_status append_to_string_field_with_length(