| 838 | */ |
| 839 | |
| 840 | YAML_DECLARE(int) |
| 841 | yaml_scalar_event_initialize(yaml_event_t *event, |
| 842 | yaml_char_t *anchor, yaml_char_t *tag, |
| 843 | yaml_char_t *value, int length, |
| 844 | int plain_implicit, int quoted_implicit, |
| 845 | yaml_scalar_style_t style) |
| 846 | { |
| 847 | yaml_mark_t mark = { 0, 0, 0 }; |
| 848 | yaml_char_t *anchor_copy = NULL; |
| 849 | yaml_char_t *tag_copy = NULL; |
| 850 | yaml_char_t *value_copy = NULL; |
| 851 | |
| 852 | assert(event); /* Non-NULL event object is expected. */ |
| 853 | assert(value); /* Non-NULL anchor is expected. */ |
| 854 | |
| 855 | if (anchor) { |
| 856 | if (!yaml_check_utf8(anchor, strlen((char *)anchor))) goto error; |
| 857 | anchor_copy = yaml_strdup(anchor); |
| 858 | if (!anchor_copy) goto error; |
| 859 | } |
| 860 | |
| 861 | if (tag) { |
| 862 | if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error; |
| 863 | tag_copy = yaml_strdup(tag); |
| 864 | if (!tag_copy) goto error; |
| 865 | } |
| 866 | |
| 867 | if (length < 0) { |
| 868 | length = (int)strlen((char *)value); |
| 869 | } |
| 870 | |
| 871 | if (!yaml_check_utf8(value, length)) goto error; |
| 872 | value_copy = yaml_malloc(length+1); |
| 873 | if (!value_copy) goto error; |
| 874 | memcpy(value_copy, value, length); |
| 875 | value_copy[length] = '\0'; |
| 876 | |
| 877 | SCALAR_EVENT_INIT(*event, anchor_copy, tag_copy, value_copy, length, |
| 878 | plain_implicit, quoted_implicit, style, mark, mark); |
| 879 | |
| 880 | return 1; |
| 881 | |
| 882 | error: |
| 883 | yaml_free(anchor_copy); |
| 884 | yaml_free(tag_copy); |
| 885 | yaml_free(value_copy); |
| 886 | |
| 887 | return 0; |
| 888 | } |
| 889 | |
| 890 | /* |
| 891 | * Create SEQUENCE-START. |
nothing calls this directly
no test coverage detected