]> andersk Git - libyaml.git/commitdiff
fix C++-compat error
authorReini Urban <rurban@cpanel.net>
Wed, 4 May 2016 06:53:47 +0000 (08:53 +0200)
committerTina Müller <cpan2@tinita.de>
Tue, 17 Jul 2018 21:08:09 +0000 (23:08 +0200)
we cannot malloc to an anon struct in C++.
typedef yaml_anchors_t

include/yaml.h
src/dumper.c
src/emitter.c

index 97f655a0216bf2f668e9ea140eb52637bfa3815c..c225908d65425b4ee699f0fa2352637e27114df8 100644 (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;
index 29fb9c078483fc8870f508fdb5c63dd6a3d8df00..1fe940b674dafd6174d086a1994568461b43f8ba 100644 (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))
index 1400df1cc45c0d5e3693eac39c55b060b7c5e677..9dc27cb9a4f58173b853890cd22526ac62dfee46 100644 (file)
@@ -16,7 +16,7 @@
 #define PUT(emitter,value)                                                      \
     (FLUSH(emitter)                                                             \
      && (*(emitter->buffer.pointer++) = (yaml_char_t)(value),                   \
-         emitter->column ++,                                                    \
+         emitter->column++,                                                    \
          1))
 
 /*
This page took 0.570062 seconds and 5 git commands to generate.