Re: GtkCList, GtkCTree and memleaks
| From: | Steph Fox | Date: | Sat, 11 Feb 2006 00:06:37 +0000 |
| Subject: | Re: GtkCList, GtkCTree and memleaks | ||
| References: | 1 2 | Groups: | php.gtk.dev |
| Request: | Send a blank email to php-gtk-dev+get-2396@lists.php.net to get a copy of this message | ||
If it's not in the CVS records obviously I didn't.
If it is you can probably take it I did.
(heck it was 7 very busy weeks ago!)
Did you ever look at treepath yet?
----- Original Message ----- From: "Andrei Zmievski" <andrei@gravitonic.com>
To: "Steph Fox" <steph@zend.com>
Cc: "PHP-GTK dev" <php-gtk-dev@lists.php.net>
Sent: Friday, February 10, 2006 5:42 AM
Subject: Re: [PHP-GTK-DEV] GtkCList, GtkCTree and memleaks
Did you ever commit this? -Andrei On Dec 18, 2005, at 12:34 PM, Steph Fox wrote:OK, I took advice on this now (thanks Tony) and the memleaks are finally dead. Need to test clist, will commit tomorrow (I don't think there's anything contentious here - it's more or less the same behaviour we had before). - Steph (gorn) ----- Original Message ----- From: "Steph Fox" <steph@zend.com> To: "Andrei" <andrei@gravitonic.com> Cc: "PHP-GTK dev" <php-gtk-dev@lists.php.net> Sent: Saturday, December 17, 2005 10:05 PM Subject: [PHP-GTK-DEV] GtkCList, GtkCTree and memleaks-- PHP-GTK Development Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __________ NOD32 1.1380 (20060125) Information __________ This message was checked by NOD32 antivirus system. http://www.eset.comAndrei, Looking into GtkCList and GtkCTree constructors, both of which need overrides to avoid the '_with_titles' variant and to get some i18n support. The first bit of code below comes directly from the php-gtk1 overrides and suffers from memory leaks:-- PHP-GTK Development Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phptarget_hash = HASH_OF(php_titles); titles = emalloc(sizeof(gchar *) * columns); zend_hash_internal_pointer_reset(target_hash);while (zend_hash_get_current_data(target_hash, (void **) &temp_title)== SUCCESS) {convert_to_string_ex(temp_title); titles[i++] = estrndup(Z_STRVAL_PP(temp_title), Z_STRLEN_PP(temp_title)); /* this leaks 1 byte per title char (+ 1) */ zend_hash_move_forward(target_hash); }The second bit of code is a much-reduced version of what I currently have:titles = emalloc(sizeof(gchar *) * columns); zend_hash_internal_pointer_reset(Z_ARRVAL_P(php_titles));while (zend_hash_get_current_data(Z_ARRVAL_P(php_titles), (void**)&temp_title) == SUCCESS) {convert_to_string_ex(temp_title); titles[i++] = Z_STRVAL_PP(temp_title); /* this doesn't leak atall, but it doesn't feel too safe either... */zend_hash_move_forward(Z_ARRVAL_P(php_titles)); }Is it better to live with the leaks in this situation? Either way works, for practical purposes... or is there a third way I didn't fall across yet? - Steph (ISP's been broken all day following stormy weather here - sorry, you'll be getting everything at once from me :-\) -- PHP-GTK Development Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php