@@ -1154,7 +1154,7 @@ yaml_emitter_check_simple_key(yaml_emitter_t *emitter)
11541154 break;
11551155
11561156 case YAML_MAPPING_START_EVENT:
1157− if (!yaml_emitter_check_empty_sequence(emitter))
1157+ if (!yaml_emitter_check_empty_mapping(emitter))
11581158 return 0;
11591159 length += emitter->anchor_data.anchor_length
11601160 + emitter->tag_data.handle_length
@@ -1349,10 +1349,15 @@ static int
13491349yaml_emitter_analyze_tag_directive(yaml_emitter_t *emitter,
13501350 yaml_tag_directive_t tag_directive)
13511351{
1352− yaml_string_t handle = STRING(tag_directive.handle,
1353− strlen((char *)tag_directive.handle));
1354− yaml_string_t prefix = STRING(tag_directive.prefix,
1355− strlen((char *)tag_directive.prefix));
1352+ yaml_string_t handle;
1353+ yaml_string_t prefix;
1354+ size_t handle_length;
1355+ size_t prefix_length;
1356+
1357+ handle_length = strlen((char *)tag_directive.handle);
1358+ prefix_length = strlen((char *)tag_directive.prefix);
1359+ STRING_ASSIGN(handle, tag_directive.handle, handle_length);
1360+ STRING_ASSIGN(prefix, tag_directive.prefix, prefix_length);
13561361
13571362 if (handle.start == handle.end) {
13581363 return yaml_emitter_set_emitter_error(emitter,
@@ -1395,7 +1400,11 @@ static int
13951400yaml_emitter_analyze_anchor(yaml_emitter_t *emitter,
13961401 yaml_char_t *anchor, int alias)
13971402{
1398− yaml_string_t string = STRING(anchor, strlen((char *)anchor));
1403+ size_t anchor_length;
1404+ yaml_string_t string;
1405+
1406+ anchor_length = strlen((char *)anchor);
1407+ STRING_ASSIGN(string, anchor, anchor_length);
13991408
14001409 if (string.start == string.end) {
14011410 return yaml_emitter_set_emitter_error(emitter, alias ?
@@ -1427,9 +1436,13 @@ static int
14271436yaml_emitter_analyze_tag(yaml_emitter_t *emitter,
14281437 yaml_char_t *tag)
14291438{
1430− yaml_string_t string = STRING(tag, strlen((char *)tag));
1439+ size_t tag_length;
1440+ yaml_string_t string;
14311441 yaml_tag_directive_t *tag_directive;
14321442
1443+ tag_length = strlen((char *)tag);
1444+ STRING_ASSIGN(string, tag, tag_length);
1445+
14331446 if (string.start == string.end) {
14341447 return yaml_emitter_set_emitter_error(emitter,
14351448 "tag value must not be empty");
@@ -1466,7 +1479,7 @@ static int
14661479yaml_emitter_analyze_scalar(yaml_emitter_t *emitter,
14671480 yaml_char_t *value, size_t length)
14681481{
1469− yaml_string_t string = STRING(value, length);
1482+ yaml_string_t string;
14701483
14711484 int block_indicators = 0;
14721485 int flow_indicators = 0;
@@ -1485,6 +1498,8 @@ yaml_emitter_analyze_scalar(yaml_emitter_t *emitter,
14851498 int previous_space = 0;
14861499 int previous_break = 0;
14871500
1501+ STRING_ASSIGN(string, value, length);
1502+
14881503 emitter->scalar_data.value = value;
14891504 emitter->scalar_data.length = length;
14901505
@@ -1772,7 +1787,11 @@ yaml_emitter_write_indicator(yaml_emitter_t *emitter,
17721787 char *indicator, int need_whitespace,
17731788 int is_whitespace, int is_indention)
17741789{
1775− yaml_string_t string = STRING((yaml_char_t *)indicator, strlen(indicator));
1790+ size_t indicator_length;
1791+ yaml_string_t string;
1792+
1793+ indicator_length = strlen(indicator);
1794+ STRING_ASSIGN(string, (yaml_char_t *)indicator, indicator_length);
17761795
17771796 if (need_whitespace && !emitter->whitespace) {
17781797 if (!PUT(emitter, ' ')) return 0;
@@ -1793,7 +1812,8 @@ static int
17931812yaml_emitter_write_anchor(yaml_emitter_t *emitter,
17941813 yaml_char_t *value, size_t length)
17951814{
1796− yaml_string_t string = STRING(value, length);
1815+ yaml_string_t string;
1816+ STRING_ASSIGN(string, value, length);
17971817
17981818 while (string.pointer != string.end) {
17991819 if (!WRITE(emitter, string)) return 0;
@@ -1809,7 +1829,8 @@ static int
18091829yaml_emitter_write_tag_handle(yaml_emitter_t *emitter,
18101830 yaml_char_t *value, size_t length)
18111831{
1812− yaml_string_t string = STRING(value, length);
1832+ yaml_string_t string;
1833+ STRING_ASSIGN(string, value, length);
18131834
18141835 if (!emitter->whitespace) {
18151836 if (!PUT(emitter, ' ')) return 0;
@@ -1830,7 +1851,8 @@ yaml_emitter_write_tag_content(yaml_emitter_t *emitter,
18301851 yaml_char_t *value, size_t length,
18311852 int need_whitespace)
18321853{
1833− yaml_string_t string = STRING(value, length);
1854+ yaml_string_t string;
1855+ STRING_ASSIGN(string, value, length);
18341856
18351857 if (need_whitespace && !emitter->whitespace) {
18361858 if (!PUT(emitter, ' ')) return 0;
@@ -1876,10 +1898,12 @@ static int
18761898yaml_emitter_write_plain_scalar(yaml_emitter_t *emitter,
18771899 yaml_char_t *value, size_t length, int allow_breaks)
18781900{
1879− yaml_string_t string = STRING(value, length);
1901+ yaml_string_t string;
18801902 int spaces = 0;
18811903 int breaks = 0;
18821904
1905+ STRING_ASSIGN(string, value, length);
1906+
18831907 if (!emitter->whitespace) {
18841908 if (!PUT(emitter, ' ')) return 0;
18851909 }
@@ -1934,10 +1958,12 @@ static int
19341958yaml_emitter_write_single_quoted_scalar(yaml_emitter_t *emitter,
19351959 yaml_char_t *value, size_t length, int allow_breaks)
19361960{
1937− yaml_string_t string = STRING(value, length);
1961+ yaml_string_t string;
19381962 int spaces = 0;
19391963 int breaks = 0;
19401964
1965+ STRING_ASSIGN(string, value, length);
1966+
19411967 if (!yaml_emitter_write_indicator(emitter, "'", 1, 0, 0))
19421968 return 0;
19431969
@@ -1995,9 +2021,11 @@ static int
19952021yaml_emitter_write_double_quoted_scalar(yaml_emitter_t *emitter,
19962022 yaml_char_t *value, size_t length, int allow_breaks)
19972023{
1998− yaml_string_t string = STRING(value, length);
2024+ yaml_string_t string;
19992025 int spaces = 0;
20002026
2027+ STRING_ASSIGN(string, value, length);
2028+
20012029 if (!yaml_emitter_write_indicator(emitter, "\"", 1, 0, 0))
20022030 return 0;
20032031
@@ -2207,9 +2235,11 @@ static int
22072235yaml_emitter_write_literal_scalar(yaml_emitter_t *emitter,
22082236 yaml_char_t *value, size_t length)
22092237{
2210− yaml_string_t string = STRING(value, length);
2238+ yaml_string_t string;
22112239 int breaks = 1;
22122240
2241+ STRING_ASSIGN(string, value, length);
2242+
22132243 if (!yaml_emitter_write_indicator(emitter, "|", 1, 0, 0))
22142244 return 0;
22152245 if (!yaml_emitter_write_block_scalar_hints(emitter, string))
@@ -2244,10 +2274,12 @@ static int
22442274yaml_emitter_write_folded_scalar(yaml_emitter_t *emitter,
22452275 yaml_char_t *value, size_t length)
22462276{
2247− yaml_string_t string = STRING(value, length);
2277+ yaml_string_t string;
22482278 int breaks = 1;
22492279 int leading_spaces = 1;
22502280
2281+ STRING_ASSIGN(string, value, length);
2282+
22512283 if (!yaml_emitter_write_indicator(emitter, ">", 1, 0, 0))
22522284 return 0;
22532285 if (!yaml_emitter_write_block_scalar_hints(emitter, string))