@@ -395,7 +395,7 @@ yaml_emitter_delete(yaml_emitter_t *emitter)
395395 }
396396 QUEUE_DEL (emitter , emitter -> events );
397397 STACK_DEL (emitter , emitter -> indents );
398- while (!STACK_EMPTY (emitter , emitter -> tag_directives )) {
398+ while (!STACK_EMPTY (empty , emitter -> tag_directives )) {
399399 yaml_tag_directive_t tag_directive = POP (emitter , emitter -> tag_directives );
400400 yaml_free (tag_directive .handle );
401401 yaml_free (tag_directive .prefix );
@@ -415,7 +415,7 @@ yaml_string_write_handler(void *data, unsigned char *buffer, size_t size)
415415{
416416 yaml_emitter_t * emitter = data ;
417417
418- if (emitter -> output .string .size + * emitter -> output .string .size_written
418+ if (emitter -> output .string .size - * emitter -> output .string .size_written
419419 < size ) {
420420 memcpy (emitter -> output .string .buffer
421421 + * emitter -> output .string .size_written ,
@@ -822,7 +822,6 @@ yaml_scalar_event_initialize(yaml_event_t *event,
822822 yaml_char_t * anchor_copy = NULL ;
823823 yaml_char_t * tag_copy = NULL ;
824824 yaml_char_t * value_copy = NULL ;
825- size_t value_length ;
826825
827826 assert (event ); /* Non-NULL event object is expected. */
828827 assert (value ); /* Non-NULL anchor is expected. */
@@ -840,19 +839,16 @@ yaml_scalar_event_initialize(yaml_event_t *event,
840839 }
841840
842841 if (length < 0 ) {
843- value_length = strlen ((char * )value );
844- }
845- else {
846- value_length = (size_t )length ;
842+ length = strlen ((char * )value );
847843 }
848844
849- if (!yaml_check_utf8 (value , value_length )) goto error ;
850- value_copy = yaml_malloc (value_length + 1 );
845+ if (!yaml_check_utf8 (value , length )) goto error ;
846+ value_copy = yaml_malloc (length + 1 );
851847 if (!value_copy ) goto error ;
852- memcpy (value_copy , value , value_length );
853- value_copy [value_length ] = '\0' ;
848+ memcpy (value_copy , value , length );
849+ value_copy [length ] = '\0' ;
854850
855- SCALAR_EVENT_INIT (* event , anchor_copy , tag_copy , value_copy , value_length ,
851+ SCALAR_EVENT_INIT (* event , anchor_copy , tag_copy , value_copy , length ,
856852 plain_implicit , quoted_implicit , style , mark , mark );
857853
858854 return 1 ;
@@ -1206,8 +1202,6 @@ yaml_document_add_scalar(yaml_document_t *document,
12061202 yaml_char_t * tag_copy = NULL ;
12071203 yaml_char_t * value_copy = NULL ;
12081204 yaml_node_t node ;
1209- size_t value_length ;
1210- ptrdiff_t ret ;
12111205
12121206 assert (document ); /* Non-NULL document object is expected. */
12131207 assert (value ); /* Non-NULL value is expected. */
@@ -1221,26 +1215,19 @@ yaml_document_add_scalar(yaml_document_t *document,
12211215 if (!tag_copy ) goto error ;
12221216
12231217 if (length < 0 ) {
1224- value_length = strlen ((char * )value );
1225- }
1226- else {
1227- value_length = (size_t )length ;
1218+ length = strlen ((char * )value );
12281219 }
12291220
1230- if (!yaml_check_utf8 (value , value_length )) goto error ;
1231- value_copy = yaml_malloc (value_length + 1 );
1221+ if (!yaml_check_utf8 (value , length )) goto error ;
1222+ value_copy = yaml_malloc (length + 1 );
12321223 if (!value_copy ) goto error ;
1233- memcpy (value_copy , value , value_length );
1234- value_copy [value_length ] = '\0' ;
1224+ memcpy (value_copy , value , length );
1225+ value_copy [length ] = '\0' ;
12351226
1236- SCALAR_NODE_INIT (node , tag_copy , value_copy , value_length , style , mark , mark );
1227+ SCALAR_NODE_INIT (node , tag_copy , value_copy , length , style , mark , mark );
12371228 if (!PUSH (& context , document -> nodes , node )) goto error ;
12381229
1239- ret = document -> nodes .top - document -> nodes .start ;
1240- #if PTRDIFF_MAX > INT_MAX
1241- if (ret > INT_MAX ) goto error ;
1242- #endif
1243- return (int )ret ;
1230+ return document -> nodes .top - document -> nodes .start ;
12441231
12451232error :
12461233 yaml_free (tag_copy );
@@ -1268,7 +1255,6 @@ yaml_document_add_sequence(yaml_document_t *document,
12681255 yaml_node_item_t * top ;
12691256 } items = { NULL , NULL , NULL };
12701257 yaml_node_t node ;
1271- ptrdiff_t ret ;
12721258
12731259 assert (document ); /* Non-NULL document object is expected. */
12741260
@@ -1286,11 +1272,7 @@ yaml_document_add_sequence(yaml_document_t *document,
12861272 style , mark , mark );
12871273 if (!PUSH (& context , document -> nodes , node )) goto error ;
12881274
1289- ret = document -> nodes .top - document -> nodes .start ;
1290- #if PTRDIFF_MAX > INT_MAX
1291- if (ret > INT_MAX ) goto error ;
1292- #endif
1293- return (int )ret ;
1275+ return document -> nodes .top - document -> nodes .start ;
12941276
12951277error :
12961278 STACK_DEL (& context , items );
@@ -1318,7 +1300,6 @@ yaml_document_add_mapping(yaml_document_t *document,
13181300 yaml_node_pair_t * top ;
13191301 } pairs = { NULL , NULL , NULL };
13201302 yaml_node_t node ;
1321- ptrdiff_t ret ;
13221303
13231304 assert (document ); /* Non-NULL document object is expected. */
13241305
@@ -1336,11 +1317,7 @@ yaml_document_add_mapping(yaml_document_t *document,
13361317 style , mark , mark );
13371318 if (!PUSH (& context , document -> nodes , node )) goto error ;
13381319
1339- ret = document -> nodes .top - document -> nodes .start ;
1340- #if PTRDIFF_MAX > INT_MAX
1341- if (ret > INT_MAX ) goto error ;
1342- #endif
1343- return (int )ret ;
1320+ return document -> nodes .top - document -> nodes .start ;
13441321
13451322error :
13461323 STACK_DEL (& context , pairs );
0 commit comments