[PATCH] a bit of Pango

From: Date: Sat, 24 Jun 2006 23:30:53 +0000
Subject: [PATCH] a bit of Pango
Groups: php.gtk.dev 
Request: Send a blank email to php-gtk-dev+get-3156@lists.php.net to get a copy of this message
More stuff, except I can't find a way to kill these memleaks.... if you can, we only have two constructors left to write. Note that leaks only occur if varargs come into the equation, I don't see any if I just have new PangoTabArray(true, Pango::TAB_LEFT, 0); My best guess is it's string-related... Any clue? $tab_array2 = new PangoTabArray(true, Pango::TAB_LEFT, 0, Pango::TAB_LEFT, 30); =============================================================================== c:\sandbox\php-gtk\main\php_gtk_util.c(738) : Freeing 0x00B36AE8 (32 bytes), script=bug.php c:\sandbox\php5\zend\zend_hash.c(169) : Actual location (location was relayed) Last leak repeated 1 time c:\sandbox\php5\zend\zend_vm_execute.h(1766) : Freeing 0x00B36968 (16 bytes), script=bug.php c:\sandbox\php5\zend\zend_vm_execute.h(4190) : Freeing 0x00B36910 (16 bytes), script=bug.php c:\sandbox\php-gtk\main\php_gtk_util.c(742) : Freeing 0x00B32020 (35 bytes), script=bug.php c:\sandbox\php5\zend\zend_hash.c(383) : Actual location (location was relayed) Last leak repeated 1 time === Total 6 memory leaks detected === $tab_array3 = new PangoTabArray(true, Pango::TAB_LEFT, 20, Pango::TAB_LEFT, 30, Pango::TAB_LEFT, 50); ===================================================================================================== c:\sandbox\php-gtk\main\php_gtk_util.c(738) : Freeing 0x00B36E60 (32 bytes), script=bug.php c:\sandbox\php5\zend\zend_hash.c(169) : Actual location (location was relayed) Last leak repeated 1 time c:\sandbox\php5\zend\zend_vm_execute.h(1766) : Freeing 0x00B36C78 (16 bytes), script=bug.php Last leak repeated 1 time c:\sandbox\php5\zend\zend_vm_execute.h(4190) : Freeing 0x00B36C20 (16 bytes), script=bug.php Last leak repeated 1 time c:\sandbox\php-gtk\main\php_gtk_util.c(742) : Freeing 0x00B32280 (35 bytes), script=bug.php c:\sandbox\php5\zend\zend_hash.c(383) : Actual location (location was relayed) Last leak repeated 3 times === Total 10 memory leaks detected === $tab_array2 = new PangoTabArray(true, Pango::TAB_LEFT, 0, Pango::TAB_LEFT, 30); $tab_array3 = new PangoTabArray(true, Pango::TAB_LEFT, 20, Pango::TAB_LEFT, 30, Pango::TAB_LEFT, 50); ===================================================================================================== c:\sandbox\php-gtk\main\php_gtk_util.c(738) : Freeing 0x00B37D50 (32 bytes), script=bug.php c:\sandbox\php5\zend\zend_hash.c(169) : Actual location (location was relayed) Last leak repeated 3 times c:\sandbox\php5\zend\zend_vm_execute.h(1766) : Freeing 0x00B37B68 (16 bytes), script=bug.php Last leak repeated 2 times c:\sandbox\php5\zend\zend_vm_execute.h(4190) : Freeing 0x00B37B10 (16 bytes), script=bug.php Last leak repeated 2 times c:\sandbox\php-gtk\main\php_gtk_util.c(742) : Freeing 0x00B32DC8 (35 bytes), script=bug.php c:\sandbox\php5\zend\zend_hash.c(383) : Actual location (location was relayed) Last leak repeated 5 times === Total 16 memory leaks detected ===

Index: ext/gtk+/pango.overrides =================================================================== RCS file: /repository/php-gtk/ext/gtk+/pango.overrides,v retrieving revision 1.7 diff -u -r1.7 pango.overrides --- ext/gtk+/pango.overrides 31 Jul 2005 10:14:44 -0000 1.7 +++ ext/gtk+/pango.overrides 24 Jun 2006 23:17:45 -0000 @@ -11,6 +11,10 @@ *_get_type %% +ignore + pango_tab_array_new_with_positions + +%% override pango_color_parse PHP_METHOD { @@ -70,3 +74,69 @@ ink.height, logical.x, logical.y, logical.width, logical.height); } + +%% +override pango_tab_array_new +PHP_METHOD +{ + zval *user_args = NULL, *php_first_alignment = NULL; + zval **position, **alignment; + PangoTabAlign first_alignment; + gint size = 0, first_position = 0; + zend_bool positions_in_pixels = FALSE; + phpg_gboxed_t *pobj = NULL; + + if (ZEND_NUM_ARGS() > 2) { + if (!php_gtk_parse_varargs(ZEND_NUM_ARGS(), 3, &user_args, "bVi", &positions_in_pixels, &php_first_alignment, &first_position)) { + PHPG_THROW_CONSTRUCT_EXCEPTION(PangoTabArray); + } + } else { + if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "|bVi", &positions_in_pixels, &php_first_alignment, &first_position)) { + PHPG_THROW_CONSTRUCT_EXCEPTION(PangoTabArray); + } + } + + if (php_first_alignment && phpg_gvalue_get_enum(PANGO_TYPE_TAB_ALIGN, php_first_alignment, (gint *)&first_alignment) == FAILURE) { + PHPG_THROW_CONSTRUCT_EXCEPTION(PangoTabArray); + } + + pobj = zend_object_store_get_object(this_ptr TSRMLS_CC); + pobj->gtype = PANGO_TYPE_TAB_ARRAY; + + if (user_args) { + + if (zend_hash_num_elements(Z_ARRVAL_P(user_args)) % 2) { + php_error(E_WARNING, "PangoTabArray::new_with_positions(): argument list should consist of alignment/position pairs"); + PHPG_THROW_CONSTRUCT_EXCEPTION(PangoTabArray); + } + + size = zend_hash_num_elements(Z_ARRVAL_P(user_args))/2; + + zend_hash_internal_pointer_reset(Z_ARRVAL_P(user_args)); + while (zend_hash_get_current_data(Z_ARRVAL_P(user_args), (void **)&alignment) == SUCCESS) { + zend_hash_move_forward(Z_ARRVAL_P(user_args)); + zend_hash_get_current_data(Z_ARRVAL_P(user_args), (void **)&position); + zend_hash_move_forward(Z_ARRVAL_P(user_args)); + + if ((Z_TYPE_PP(alignment) != IS_STRING && Z_TYPE_PP(alignment) != IS_LONG) || Z_TYPE_PP(position) != IS_LONG) { + php_error(E_WARNING, "PangoTabArray::new_with_positions(): each alignment/position pair has to be PangoTabAlign/number"); + PHPG_THROW_CONSTRUCT_EXCEPTION(PangoTabArray); + } + } + } + + if (ZEND_NUM_ARGS() > 2) { + size = size + 1; + pobj->boxed = pango_tab_array_new_with_positions(size, positions_in_pixels, first_alignment, first_position, user_args); + if (user_args) { + efree(user_args); + } + } else { + pobj->boxed = pango_tab_array_new(size, positions_in_pixels); + } + + if (!pobj->boxed) { + PHPG_THROW_CONSTRUCT_EXCEPTION(PangoTabArray); + } + pobj->free_on_destroy = TRUE; +}
« previous php.gtk.dev (#3156) next »