logo       

GtkCList, GtkCTree and memleaks: msg#00028

Subject: GtkCList, GtkCTree and memleaks
Andrei,

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:


       target_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 at
all, 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




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe