Re: Re: Convert zval array to char **

From: Date: Sat, 23 Jul 2005 15:46:13 +0000
Subject: Re: Re: Convert zval array to char **
References: 1 2 3  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-2649@lists.php.net to get a copy of this message
> So where would one find out about safe_emalloc. > Reader's Digest Versions: safe_emalloc(x,y,z) == emalloc( (x*y) + z) emalloc(){and family} differs from malloc() {and family} in that any memory allocated is implicitly freed at the end of a request. Hooray for not-leaking! pemalloc() {and family} are a combination of emalloc() and malloc() using an additional parameter to decide which version to use. For example: pemalloc(size, 0) == emalloc(size), while pemalloc(size, 1) == malloc(size). persistent==1 allows some memory blocks to be allocated such they they will PERSIST beyond an individual request. > As well as for the "RETVAL_STRING" and all those Macros. > I touched on this in http://www.zend.com/php/internals/extension-writing2.php#Heading4 In this case, the RETURN_LONG() example would look like the following where each version below behaves identically: RETURN_STRING(strval, dup); RETVAL_STRING(strval, dup); return; ZVAL_STRING(return_value, strval, dup); return; Z_TYPE_P(return_value) = IS_STRING; if (dup) { Z_STRVAL_P(return_value) = estrdup(strval); } else { Z_STRVAL_P(return_value) = strval; } Z_STRLEN_P(return_value) = strlen(strval); return; return_value->type = IS_STRING; if (dup) { return_value->value.str.val = estrdup(strval); } else { return_value->value.str.val = strval; } return_value->value.str.len = strlen(strval); return; In your function I suggested the use of RETVAL_STRING() over RETURN_STRING() because you needed the opportunity to call freeHash() before leaving the function. -Sara

« previous php.pecl.dev (#2649) next »