From: Reini Urban Date: Wed, 4 May 2016 06:53:47 +0000 (+0200) Subject: fix C++-compat error X-Git-Tag: upstream/0.2.2^2~12 X-Git-Url: http://andersk.mit.edu/gitweb/libyaml.git/commitdiff_plain/75eddf785fedc2aeb9bf96db5a9bee97f7e4e72e fix C++-compat error we cannot malloc to an anon struct in C++. typedef yaml_anchors_t --- diff --git a/include/yaml.h b/include/yaml.h index 97f655a..c225908 100644 --- a/include/yaml.h +++ b/include/yaml.h @@ -1517,6 +1517,18 @@ typedef enum yaml_emitter_state_e { YAML_EMIT_END_STATE } yaml_emitter_state_t; + +/* This is needed for C++ */ + +typedef struct yaml_anchors_s { + /** The number of references. */ + int references; + /** The anchor id. */ + int anchor; + /** If the node has been emitted? */ + int serialized; +} yaml_anchors_t; + /** * The emitter structure. * @@ -1742,14 +1754,7 @@ typedef struct yaml_emitter_s { int closed; /** The information associated with the document nodes. */ - struct { - /** The number of references. */ - int references; - /** The anchor id. */ - int anchor; - /** If the node has been emitted? */ - int serialized; - } *anchors; + yaml_anchors_t *anchors; /** The last assigned anchor id. */ int last_anchor_id; diff --git a/src/dumper.c b/src/dumper.c index 29fb9c0..1fe940b 100644 --- a/src/dumper.c +++ b/src/dumper.c @@ -131,7 +131,7 @@ yaml_emitter_dump(yaml_emitter_t *emitter, yaml_document_t *document) assert(emitter->opened); /* Emitter should be opened. */ - emitter->anchors = yaml_malloc(sizeof(*(emitter->anchors)) + emitter->anchors = (yaml_anchors_t*)yaml_malloc(sizeof(*(emitter->anchors)) * (document->nodes.top - document->nodes.start)); if (!emitter->anchors) goto error; memset(emitter->anchors, 0, sizeof(*(emitter->anchors)) diff --git a/src/emitter.c b/src/emitter.c index 1400df1..9dc27cb 100644 --- a/src/emitter.c +++ b/src/emitter.c @@ -16,7 +16,7 @@ #define PUT(emitter,value) \ (FLUSH(emitter) \ && (*(emitter->buffer.pointer++) = (yaml_char_t)(value), \ - emitter->column ++, \ + emitter->column++, \ 1)) /*