From: sgunderson@bigfoot.com <> Date: Thu, 22 Sep 2011 21:22:09 +0000 (+0200) Subject: Leak a little less memory in php5-swig. X-Git-Url: https://git.sesse.net/?p=xml-template;a=commitdiff_plain;h=2cb15f2dccf0c8966ac064389146b0e84a1cfa07 Leak a little less memory in php5-swig. --- diff --git a/php5-swig/attribute-empty.php b/php5-swig/attribute-empty.php index 5a33f63..3886e7d 100644 --- a/php5-swig/attribute-empty.php +++ b/php5-swig/attribute-empty.php @@ -5,7 +5,7 @@ dl("XML_Template_SWIG.so"); # NULL values are ignored, but having one helps pointing out that # the array given is non-associative -$doc = process_file('../xml/clone.xml', array( +$doc = XML_Template_process_file('../xml/clone.xml', array( 'color' => 'blue', '#things' => array(NULL) ), true); diff --git a/php5-swig/attribute.php b/php5-swig/attribute.php index fa5a0df..d63cf69 100644 --- a/php5-swig/attribute.php +++ b/php5-swig/attribute.php @@ -1,7 +1,7 @@ 'red', '#things' => array( array( 'li' => 'Raindrops on roses', 'li/class' => 'odd' ), diff --git a/php5-swig/attribute2.php b/php5-swig/attribute2.php index adcad31..4b33237 100644 --- a/php5-swig/attribute2.php +++ b/php5-swig/attribute2.php @@ -1,7 +1,7 @@ 'blue', '#things' => XML_Template_alternate('li/class', array( array( 'li' => 'Raindrops on roses' ), diff --git a/php5-swig/attribute3.php b/php5-swig/attribute3.php index 8b84e7d..f3afc60 100644 --- a/php5-swig/attribute3.php +++ b/php5-swig/attribute3.php @@ -1,7 +1,7 @@ 'blue', '#things' => XML_Template_alternate('li/class', array( array( 'li' => 'Raindrops on roses' ), diff --git a/php5-swig/clone.php b/php5-swig/clone.php index abe0e30..a0f98a7 100644 --- a/php5-swig/clone.php +++ b/php5-swig/clone.php @@ -1,7 +1,7 @@ 'blue', '#things' => array( array( 'li' => 'Raindrops on roses' ), diff --git a/php5-swig/include.php b/php5-swig/include.php index 5e3ff4e..a648bb5 100644 --- a/php5-swig/include.php +++ b/php5-swig/include.php @@ -1,10 +1,10 @@ 'red' ), 0); -$master = process_file('../xml/master.xml', array( +$master = XML_Template_process_file('../xml/master.xml', array( 'title' => 'Main HTML title', 'h1' => 'Nice heading here', 'contents' => $doc diff --git a/php5-swig/namespace.php b/php5-swig/namespace.php index 1dfc9b9..f17fb74 100644 --- a/php5-swig/namespace.php +++ b/php5-swig/namespace.php @@ -1,7 +1,7 @@ 'Namespace tests', '#hello' => 'Hello world!', '#test' => 'Replaced.', diff --git a/php5-swig/namespace2.php b/php5-swig/namespace2.php index a4c4426..06c7bd6 100644 --- a/php5-swig/namespace2.php +++ b/php5-swig/namespace2.php @@ -1,7 +1,7 @@ 'Namespace tests', '#hello' => 'Replaced.', ), true); diff --git a/php5-swig/passthru.php b/php5-swig/passthru.php index 8102a38..3b3822b 100644 --- a/php5-swig/passthru.php +++ b/php5-swig/passthru.php @@ -1,7 +1,7 @@ diff --git a/php5-swig/simple.php b/php5-swig/simple.php index 44cbd2f..2f29d51 100644 --- a/php5-swig/simple.php +++ b/php5-swig/simple.php @@ -1,7 +1,7 @@ 'A very basic example', '#hello' => 'Hello world!' ), true); diff --git a/php5-swig/structure.php b/php5-swig/structure.php index c3a684e..2bc8c44 100644 --- a/php5-swig/structure.php +++ b/php5-swig/structure.php @@ -1,7 +1,7 @@ array( array( '#inner' => 'One' ), array( '#inner' => 'Two' ), diff --git a/php5-swig/xml-template.swig b/php5-swig/xml-template.swig index 8a915ff..2feceba 100644 --- a/php5-swig/xml-template.swig +++ b/php5-swig/xml-template.swig @@ -68,12 +68,19 @@ Directive* convert_php_objects_to_directive(zval *obj) return NULL; } +xmlDocPtr XML_Template_process_file(const char *input_filename, Directive *root_directive, bool clean) +{ + xmlDocPtr ret = process_file(input_filename, root_directive, clean); + delete root_directive; + return ret; +} + %} %typemap(in) Directive* { $1 = convert_php_objects_to_directive(*$input); } -xmlDocPtr process_file(const char *input_filename, Directive *root_directive, bool clean); +xmlDocPtr XML_Template_process_file(const char *input_filename, Directive *root_directive, bool clean); void output_to_fd_and_free(xmlDocPtr doc, int fd);