aboutsummaryrefslogtreecommitdiff
path: root/treexpr.c
diff options
context:
space:
mode:
authorDavid Barksdale <amatus.amongus@gmail.com>2006-04-24 02:28:12 +0000
committerDavid Barksdale <amatus.amongus@gmail.com>2006-04-24 02:28:12 +0000
commitcf308c8cdbc3209f31d45f5ed28929f699d9837c (patch)
tree5d55fb305c117c7caf1001ac5e89e4c171c6cafa /treexpr.c
parentaeb110d90df145ac99009c1a7b9e3077d6b457a6 (diff)
Fixing some formatting issues, added a free_matches function to handle the
freeing of memory allocated in process_document, this function is now used in the GrockHtml class to fix a memory leak.
Diffstat (limited to 'treexpr.c')
-rw-r--r--treexpr.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/treexpr.c b/treexpr.c
index eb68f2e..3b6a836 100644
--- a/treexpr.c
+++ b/treexpr.c
@@ -1143,3 +1143,21 @@ struct match *document_process( struct machine *m, xmlDocPtr doc )
{
return node_recurse( m, doc->children->next, NULL );
}
+
+// free matches returned by document_process
+void free_matches( struct match *z )
+{
+ struct match *nextz;
+ struct regex_match *nextre;
+
+ for( ; z != NULL; z = nextz )
+ {
+ nextz = z->next;
+ for( ; z->re != NULL; z->re = nextre )
+ {
+ nextre = z->re->next;
+ free( z->re );
+ }
+ free( z );
+ }
+}