RE: [PHP-DEV] Memory leak and possible cause of bug #15333
| From: | Joseph Tate | Date: | Mon, 08 Apr 2002 19:33:58 +0000 |
| Subject: | RE: [PHP-DEV] Memory leak and possible cause of bug #15333 | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-82286@lists.php.net to get a copy of this message | ||
I don't follow you. Why does it need to be copied? c->name already
contains the value. Old? New? c is c is c. Commenting out the code
causes other problems elsewhere (or seems to). I just don't understand why
it has to be done.
> -----Original Message-----
> --- Joseph Tate <jtate@mi-corporation.com> wrote:
> > in the copy_zend_constant function it reads:
> >
> > void copy_zend_constant(zend_constant *c)
> > {
> > c->name = zend_strndup(c->name, c->name_len);
> > if (!(c->flags & CONST_PERSISTENT)) {
> > zval_copy_ctor(&c->value);
> > if (c->flags & CONST_EFREE_PERSISTENT) { /*
> persist_alloc()'d data */
> > persist_alloc(&c->value);
> > }
> > }
> > }
> >
> > I draw your attention to the first line in the function:
> > c->name = zend_strndup(c->name, c->name_len);
> >
> > First of all, why is this string duplicated only to store it to the same
> > location? Secondly, is c->name freed somewhere else? Cause I
> can't see it
> > being freed. Seems like this line can be removed...
> >
>
> So c points to the "old" value and you need to copy the name and
> the value to
> the "new" one, name and value. and the way hashes and emalloc
> works the memory
> will be freed automatically.
>
>