> Im pretty sure you still need to 'efree' what you 'emalloc'.  Every time
> I forgot to 'efree' something, I would get a bunch of error messages
> about memory leaks.  The errors were nice and verbose, tho... as long as
> I was running the debug version of the dlls.

Which is what I would have assumed, but for what I read in the manual.

> So either the documentation is wrong, and you have to efree
> everything... or else the error messages about memory leaks that I keep
> getting can be ignored...
>
> I'd be curious to know the answer as well...

Well, I decided to see how the big boys dealt with strings, and had a root
around ext/standard.  The following function is from string.c:

PHP_FUNCTION(bin2hex)
{
        zval **data;
        char *result;
        size_t newlen;

        if (ZEND_NUM_ARGS() != 1 ||
        zend_get_parameters_ex(1, &data) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
        convert_to_string_ex(data);

        result = php_bin2hex(Z_STRVAL_PP(data), Z_STRLEN_PP(data), &newlen);

        if (!result) {
                RETURN_FALSE;
        }

        RETURN_STRINGL(result, newlen, 0);
}

As you can see, result is emalloc()'d, but not efree()'d at the end - looks
like the docs are right.  I have since tried using this approach in a test
function and do not get any errors when I compile - what do you use for your
build?

regards,

Mikey



-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to