# zend_class_entry memory leak ?

- Thread: https://externals.io/message/884
- Original archive: https://news-web.php.net/php.internals/884
- Started by l0t3k on 2003-04-13T07:13:04+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #884 — l0t3k — 2003-04-13T07:13:04+00:00

URL: https://externals.io/message/884#884

i have the following code to register class constants :

void register_class_long_constant_ex(zend_class_entry *ce, char *key, uint
key_len, long lval)
{
 HashTable *ht = &(ce)->constants_table;
 zval *tmp;
 MAKE_STD_ZVAL(tmp);
 ZVAL_LONG(tmp, lval);
 zend_hash_update(ht, key, key_len, (void *) &tmp, sizeof(zval *), NULL);
}

on shutdown, i get a report of a leak at MAKE_STD_ZVAL, once for each
constant defined. am i doing something wrong, or is the class constant table
not properly destructed ?

l0t3k

---

## #885 — marcus.boerger@t-online.de — 2003-04-13T10:33:21+00:00

URL: https://externals.io/message/884#885 · In reply to: #884

At 09:13 13.04.2003, l0t3k wrote:
>i have the following code to register class constants :
>
>[...]
>
>on shutdown, i get a report of a leak at MAKE_STD_ZVAL, once for each
>constant defined. am i doing something wrong, or is the class constant table
>not properly destructed ?


You should use internal classes and do everything that needs memory
with malloc/realoc/free instead of the e functions. The problem is the shutdown
sequence.

marcus

---

## #886 — l0t3k — 2003-04-13T11:15:01+00:00

URL: https://externals.io/message/884#886 · In reply to: #885

> You should use internal classes and do everything that needs memory
> with malloc/realoc/free instead of the e functions. The problem is the
shutdown
> sequence.
Marcus,
  thanks for responding. im confused about what you mean by internal classes
though. do you have a basic example ?

l0t3k

---

## #887 — marcus.boerger@t-online.de — 2003-04-13T12:04:15+00:00

URL: https://externals.io/message/884#887 · In reply to: #885

At 13:15 13.04.2003, l0t3k wrote:

> > […]
>shutdown
> > […]
>Marcus,
>   thanks for responding. im confused about what you mean by internal classes
>though. do you have a basic example ?

If you use any of the follwoing functions (as you should do):
ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry 
*class_entry TSRMLS_DC);
ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry 
*class_entry, zend_class_entry *parent_ce, char *parent_name TSRMLS_DC);
ZEND_API zend_class_entry *zend_register_internal_ns_class(zend_class_entry 
*class_entry, zend_class_entry *parent_ce, zend_namespace *ns, char 
*ns_name TSRMLS_DC);
ZEND_API zend_namespace *zend_register_internal_namespace(zend_namespace 
*ns TSRMLS_DC);

then you can't use any of emallo/erealloc/efree thats all you must know.

marcus
