summaryrefslogtreecommitdiff
path: root/ext/syck/syck.c
diff options
context:
space:
mode:
authorwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-14 20:01:09 +0000
committerwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-14 20:01:09 +0000
commitf5a6a36471123985aa452b6c03d1667c4e447d29 (patch)
tree8443bb4cdace2625febeacf6e9dccf45952742d7 /ext/syck/syck.c
parentcf13323ff4bd0214fed144907637bd149f283989 (diff)
* ext/syck/gram.c: sequence-in-map shortcut, transfer methods on
sequence-in-sequence, memory leak in mapping merge. [0.28] * ext/syck/syck.c: memory leak in domain anchoring. [0.28] * lib/yaml/rubytypes.rb, lib/yaml/types.rb: eliminated 1.6.x code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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 76edc902d0c..fdec7a95e2f 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 );