summaryrefslogtreecommitdiff
path: root/ext/syck/syck.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/syck/syck.c')
-rw-r--r--ext/syck/syck.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/ext/syck/syck.c b/ext/syck/syck.c
index 76edc90..fdec7a9 100644
--- a/ext/syck/syck.c
+++ b/ext/syck/syck.c
@@ -107,10 +107,18 @@ syck_io_str_read( char *buf, SyckIoStr *str, long max_size, long skip )
void
syck_parser_reset_levels( SyckParser *p )
{
- p->lvl_idx = 1;
- p->levels[0].spaces = -1;
- p->levels[0].domain = syck_strndup( "", 1 ); // YAML_DOMAIN + "/";
- p->levels[0].status = syck_lvl_header;
+ while ( p->lvl_idx > 1 )
+ {
+ syck_parser_pop_level( p );
+ }
+
+ if ( p->lvl_idx < 1 )
+ {
+ p->lvl_idx = 1;
+ p->levels[0].spaces = -1;
+ p->levels[0].domain = ""; // YAML_DOMAIN + "/";
+ p->levels[0].status = syck_lvl_header;
+ }
}
void
@@ -153,6 +161,7 @@ syck_new_parser()
p->taguri_expansion = 0;
p->bufsize = SYCK_BUFFERSIZE;
p->buffer = NULL;
+ p->lvl_idx = 0;
syck_parser_reset_levels( p );
return p;
}
@@ -166,7 +175,7 @@ syck_add_sym( SyckParser *p, char *data )
p->syms = st_init_numtable();
}
id = p->syms->num_entries;
- st_insert( p->syms, id, (st_data_t)data );
+ st_insert( p->syms, id, data );
return id;
}
@@ -174,10 +183,10 @@ int
syck_lookup_sym( SyckParser *p, SYMID id, char **data )
{
if ( p->syms == NULL ) return 0;
- return st_lookup( p->syms, id, (st_data_t *)data );
+ return st_lookup( p->syms, id, data );
}
-int
+enum st_retval
syck_st_free_nodes( char *key, SyckNode *n, char *arg )
{
syck_free_node( n );
@@ -201,13 +210,15 @@ syck_free_parser( SyckParser *p )
//
// Free the anchor table
//
- st_foreach( p->anchors, syck_st_free_nodes, 0 );
+ st_foreach( p->anchors, syck_st_free_nodes, NULL );
st_free_table( p->anchors );
//
// Free all else
//
+ syck_parser_reset_levels( p );
S_FREE( p->levels );
+
if ( p->buffer != NULL )
{
S_FREE( p->buffer );