# freeing zvals ref count

- Thread: https://externals.io/message/60300
- Original archive: https://news-web.php.net/php.internals/60300
- Started by Yader Hernandez on 2012-04-24T23:25:39+00:00
- Messages: 2
- 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

---

## #60300 — Yader Hernandez — 2012-04-24T23:25:39+00:00

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

Hello,

In the extension I'm currently working on, I call add_index_zval and on
success, I call Z_ADDREF_P on the new zval.

When I'm freeing everything, I need to remove the ref count. Digging
through the source code, I found Z_DELREF_P. Would this be the correct
macro to call? Is there anything else to keep in mind when calling it?

thx

---

## #60302 — Etienne Kneuss — 2012-04-24T23:28:35+00:00

URL: https://externals.io/message/60300#60302 · In reply to: #60300

Hi,

On Wed, Apr 25, 2012 at 01:25, Yader Hernandez
<yader.hernandez@gmail.com> wrote:
> Hello,
>
> In the extension I'm currently working on, I call add_index_zval and on
> success, I call Z_ADDREF_P on the new zval.
>
> When I'm freeing everything, I need to remove the ref count. Digging
> through the source code, I found Z_DELREF_P. Would this be the correct
> macro to call? Is there anything else to keep in mind when calling it?

You should use zval_ptr_dtor instead. it will delref and free in case
the refcount hits 0.

Best,

>
> thx



-- 
Etienne Kneuss
http://www.colder.ch
