Hi Sara, All right. I haven't objections. Also, please update ..._ASCII_STRING() macros family to use these flags. They have exactly the same problem.
Thanks. Dmitry. > -----Original Message----- > From: Sara Golemon [mailto:[EMAIL PROTECTED] > Sent: Thursday, April 06, 2006 2:27 AM > To: internals@lists.php.net > Cc: Dmitry Stogov > Subject: Re: [PHP-DEV] RETURN_RT_STRING() and family leakage > > > Here's what I plan to commit unless I hear otherwise. > > I went with ZSTR_ as the prefix for the constants as S_ isn't > terribly unique. If anyone has a better suggestion, now is > the time to voice it. > > -Sara > > ----- Original Message ----- > From: Dmitry Stogov > To: 'Sara Golemon' > Cc: internals@lists.php.net > Sent: Monday, April 03, 2006 10:02 PM > Subject: RE: [PHP-DEV] RETURN_RT_STRING() and family leakage > > > I prefer (2) or (3). > (3) requires less changes. > > #define S_DUPLICATE (1<<0) > #define S_AUTO_FREE (1<<1) > > #define ZVAL_U_STRINGL(conv, z, s, l, flags) \ > if (UG(unicode)) { \ > UErrorCode status = U_ZERO_ERROR; \ > UChar *u_str; \ > int u_len; \ > zend_convert_to_unicode(conv, &u_str, &u_len, s, l, > &status); \ > ZVAL_UNICODEL(z, u_str, u_len, 0); \ > if (flags & S_AUTO_FREE) {efree(s);} \ > } else { \ > char *__s=(s); int __l=l; \ > Z_STRLEN_P(z) = __l; \ > Z_STRVAL_P(z) = ((flags & S_DUPLICATE)?estrndup(__s, > __l):__s); \ > Z_TYPE_P(z) = IS_STRING; \ > } > > And then we need to change only calls those rally leak. > > RETURN_RT_STRING(str, 1) -> RETURN_RT_STRING(str, S_DUPLICATE > | S_AUTO_FREE) > > Thanks. Dmitry. > > > -----Original Message----- > > From: Sara Golemon [mailto:[EMAIL PROTECTED] > > Sent: Monday, April 03, 2006 10:15 PM > > To: "Dmitry Stogov" > > Cc: internals@lists.php.net > > Subject: Re: [PHP-DEV] RETURN_RT_STRING() and family leakage > > > > > > >> duplicate should only ever be set to 0 on this (or any of the > > >> macros) when > > >> the string *is* allocated with emalloc. Otherwise the > > enegine would > > >> get in trouble freeing it later on. > > > > > > No. :( > > > You can use ZVAL_RT_STRING(&fname, "strlen", 0), then call > > > zend_call_function(&fname) and do not destroy fname. > > > > > Doi, of course, good point... > > > > Okay, then the options are: > > > > (1) Assume auto_free for RETURN_RT_STRING(s,0) specifically > as in this > > case, my statement above is valid since the engine IS going to try > > it eventually. > > Leave all other macros alone and make the calling scope > > handle the original > > string with the existing if (UG(unicode)) efree(s); Not > my favorite. > > > > (2) Expand (ZVAL|RETVAL)_RT_STRING(s, 0) to include auto_free > > argument. This coule be done in conjunction with (1) or in place of > > it. > > > > (3) Overload duplicate argument to include (should I > > auto-free?) logic. > > > > (4) Duplicate the macros to one auto-free, and one non-auto-free > > version. > > > > I like the #1/#2 combo personally. > > > > -Sara > > > > > > > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php