cvs: php-gtk /ext/gtk+ gtk.overrides php_gtk+.h
| From: | Markus Fischer | Date: | Sat, 08 Dec 2001 13:49:13 +0000 |
| Subject: | cvs: php-gtk /ext/gtk+ gtk.overrides php_gtk+.h | ||
| Groups: | php.gtk.cvs | ||
| Request: | Send a blank email to php-gtk-cvs+get-399@lists.php.net to get a copy of this message | ||
mfischer Sat Dec 8 08:49:13 2001 EDT
Modified files:
/php-gtk/ext/gtk+ gtk.overrides php_gtk+.h
Log:
- Separate to a more finer grained function and make them available for
other extensions.
Index: php-gtk/ext/gtk+/gtk.overrides
diff -u php-gtk/ext/gtk+/gtk.overrides:1.35 php-gtk/ext/gtk+/gtk.overrides:1.36
--- php-gtk/ext/gtk+/gtk.overrides:1.35 Sat Dec 8 07:56:02 2001
+++ php-gtk/ext/gtk+/gtk.overrides Sat Dec 8 08:49:13 2001
@@ -2768,23 +2768,29 @@
return 0;
}
+/* Free a NULL terminated list of gchar pointers */
+void php_gtk_free_gchar_array(gchar **gchar_array)
+{
+ int i = 0;
+ while (gchar_array[i]) {
+ efree(gchar_array[i++]);
+ }
+}
+
/* Simply traverse the array and free what is available. If you know you haven't allocated
* all of the entries you can pass the actual number of entries allocated; else just
* pass the maximum size (but be sure to have proper initialized the array to 0 first). */
-void php_gtk_free_gchar_array(gchar ***gchar_array, int num_elements)
+void php_gtk_free_gchar_ptr_array(gchar ***gchar_ptr_array, int num_elements)
{
int i, j;
for (i = 0; i < num_elements; i++) {
- if (gchar_array[i]) {
- j = 0;
- while (gchar_array[i][j]) {
- efree(gchar_array[i][j++]);
- }
- efree(gchar_array[i]);
+ if (gchar_ptr_array[i]) {
+ php_gtk_free_gchar_array(gchar_ptr_array[i]);
+ efree(gchar_ptr_array[i]);
}
}
- efree(gchar_array);
+ efree(gchar_ptr_array);
}
static void set_filter(INTERNAL_FUNCTION_PARAMETERS, int which)
@@ -2834,7 +2840,7 @@
if (!php_gtk_array_to_gchar_array(php_args[i], &(parameters[i]))) {
php_error(E_WARNING, "%s() expected argument %d to be NULL, string or array of strings; %s
given",
get_active_function_name(TSRMLS_C), 3 + i, php_gtk_zval_type_name(php_args[i]));
- php_gtk_free_gchar_array(parameters, i - 1);
+ php_gtk_free_gchar_ptr_array(parameters, i - 1);
return;
}
}
@@ -2860,7 +2866,7 @@
}
/* Free the parameters we previously allocated */
- php_gtk_free_gchar_array(parameters, num_parameters);
+ php_gtk_free_gchar_ptr_array(parameters, num_parameters);
}
PHP_FUNCTION(gtk_font_selection_set_filter)
Index: php-gtk/ext/gtk+/php_gtk+.h
diff -u php-gtk/ext/gtk+/php_gtk+.h:1.9 php-gtk/ext/gtk+/php_gtk+.h:1.10
--- php-gtk/ext/gtk+/php_gtk+.h:1.9 Tue Nov 13 04:17:43 2001
+++ php-gtk/ext/gtk+/php_gtk+.h Sat Dec 8 08:49:13 2001
@@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: php_gtk+.h,v 1.9 2001/11/13 09:17:43 mfischer Exp $: */
+/* $Id: php_gtk+.h,v 1.10 2001/12/08 13:49:13 mfischer Exp $: */
#ifndef _PHP_GTK_PLUS_H
#define _PHP_GTK_PLUS_H
@@ -120,5 +120,9 @@
void php_gtk_register_classes(void);
void php_gdk_register_classes(void);
void php_gtk_plus_register_types(int module_number);
+
+int php_gtk_array_to_gchar_array(zval *zvalue, gchar ***gchar_array);
+void php_gtk_free_gchar_array(gchar **gchar_array);
+void php_gtk_free_gchar_ptr_array(gchar ***gchar_ptr_array, int num_elements);
#endif /* _PHP_GTK_PLUS_H */