mirror of
https://github.com/yaml/libyaml.git
synced 2026-01-26 19:19:02 +00:00
fix C++-compat error
we cannot malloc to an anon struct in C++. typedef yaml_anchors_t
This commit is contained in:
parent
20496ee288
commit
75eddf785f
@ -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;
|
||||
|
||||
@ -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))
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
#define PUT(emitter,value) \
|
||||
(FLUSH(emitter) \
|
||||
&& (*(emitter->buffer.pointer++) = (yaml_char_t)(value), \
|
||||
emitter->column ++, \
|
||||
emitter->column++, \
|
||||
1))
|
||||
|
||||
/*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user