| 480 | */ |
| 481 | |
| 482 | static int |
| 483 | yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *event, |
| 484 | struct loader_ctx *ctx) |
| 485 | { |
| 486 | yaml_node_t node; |
| 487 | struct { |
| 488 | yaml_node_pair_t *start; |
| 489 | yaml_node_pair_t *end; |
| 490 | yaml_node_pair_t *top; |
| 491 | } pairs = { NULL, NULL, NULL }; |
| 492 | int index; |
| 493 | yaml_char_t *tag = event->data.mapping_start.tag; |
| 494 | |
| 495 | if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error; |
| 496 | |
| 497 | if (!tag || strcmp((char *)tag, "!") == 0) { |
| 498 | yaml_free(tag); |
| 499 | tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_MAPPING_TAG); |
| 500 | if (!tag) goto error; |
| 501 | } |
| 502 | |
| 503 | if (!STACK_INIT(parser, pairs, yaml_node_pair_t*)) goto error; |
| 504 | |
| 505 | MAPPING_NODE_INIT(node, tag, pairs.start, pairs.end, |
| 506 | event->data.mapping_start.style, |
| 507 | event->start_mark, event->end_mark); |
| 508 | |
| 509 | if (!PUSH(parser, parser->document->nodes, node)) goto error; |
| 510 | |
| 511 | index = parser->document->nodes.top - parser->document->nodes.start; |
| 512 | |
| 513 | if (!yaml_parser_register_anchor(parser, index, |
| 514 | event->data.mapping_start.anchor)) return 0; |
| 515 | |
| 516 | if (!yaml_parser_load_node_add(parser, ctx, index)) return 0; |
| 517 | |
| 518 | if (!STACK_LIMIT(parser, *ctx, INT_MAX-1)) return 0; |
| 519 | if (!PUSH(parser, *ctx, index)) return 0; |
| 520 | |
| 521 | return 1; |
| 522 | |
| 523 | error: |
| 524 | yaml_free(tag); |
| 525 | yaml_free(event->data.mapping_start.anchor); |
| 526 | return 0; |
| 527 | } |
| 528 | |
| 529 | static int |
| 530 | yaml_parser_load_mapping_end(yaml_parser_t *parser, yaml_event_t *event, |
no test coverage detected