DNAYaml: Correctly initialize yaml events

This commit is contained in:
Luke Street 2020-06-10 00:13:49 -04:00
parent dec27c05ed
commit 1b8b7f6819
1 changed files with 3 additions and 6 deletions

View File

@ -441,8 +441,6 @@ bool YAMLDocWriter::finish(athena::io::IStreamWriter* fout) {
return false; return false;
}; };
yaml_event_t event = {};
if (fout) { if (fout) {
yaml_emitter_set_output(&m_emitter, (yaml_write_handler_t*)YAMLAthenaWriter, fout); yaml_emitter_set_output(&m_emitter, (yaml_write_handler_t*)YAMLAthenaWriter, fout);
} }
@ -450,16 +448,15 @@ bool YAMLDocWriter::finish(athena::io::IStreamWriter* fout) {
return error(); return error();
} }
event.type = YAML_DOCUMENT_START_EVENT; yaml_event_t event;
event.data.document_start.implicit = true; yaml_document_start_event_initialize(&event, nullptr, nullptr, nullptr, 1);
if (!yaml_emitter_emit(&m_emitter, &event)) { if (!yaml_emitter_emit(&m_emitter, &event)) {
return error(); return error();
} }
if (!RecursiveFinish(&m_emitter, *m_rootNode)) { if (!RecursiveFinish(&m_emitter, *m_rootNode)) {
return false; return false;
} }
event.type = YAML_DOCUMENT_END_EVENT; yaml_document_end_event_initialize(&event, 1);
event.data.document_end.implicit = true;
if (!yaml_emitter_emit(&m_emitter, &event)) { if (!yaml_emitter_emit(&m_emitter, &event)) {
return error(); return error();
} }