fix C++-compat error

we cannot malloc to an anon struct in C++.
typedef yaml_anchors_t
This commit is contained in:
Reini Urban 2016-05-04 08:53:47 +02:00 committed by Tina Müller
parent 20496ee288
commit 75eddf785f
3 changed files with 15 additions and 10 deletions

View File

@ -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;

View File

@ -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))

View File

@ -16,7 +16,7 @@
#define PUT(emitter,value) \
(FLUSH(emitter) \
&& (*(emitter->buffer.pointer++) = (yaml_char_t)(value), \
emitter->column ++, \
emitter->column++, \
1))
/*