# Question regarding extension function entries.

- Thread: https://externals.io/message/23853
- Original archive: https://news-web.php.net/php.internals/23853
- Started by Matt Sicker on 2006-06-01T16:26:55+00:00
- Messages: 3
- 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

---

## #23853 — Matt Sicker — 2006-06-01T16:26:55+00:00

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

According to all documentation I've found, a zend_function_entry[] array
should be ended with { NULL, NULL, `NULL` }, but I've noticed that
_zend_function_entry now has five parts; differences:

-unsigned char *func_arg_types;
+struct _zend_arg_info *arg_info;
+zend_uint num_args;
+zend_uint flags;

Technically, it would make sense to end the array with five NULLs instead
of three, but that doesn't seem to be reflected by
'ext/skeleton/skeleton.c', so I don't know if it's a necessary change or
not.  If it should be changed, I'd also recommend making a macro for the
ending so that this sort of problem won't pop up again in the future, and
it would also make more sense than just having seemingly random NULLs
which could be better described with a macro.

---

## #23854 — Sara Golemon — 2006-06-01T16:58:35+00:00

URL: https://externals.io/message/23853#23854 · In reply to: #23853

> According to all documentation I've found, a
> zend_function_entry[] array should be ended
> with { NULL, NULL, `NULL` }, but I've noticed
> that _zend_function_entry now has five parts;
>
Your analysis is correct, however(functionally speaking) the only attribute 
that NEEDs to be explicitly set `NULL` is fname.  The rest can be garbage and 
everything will still function fine.  The second and third elements are set 
 `NULL` becasue they can be safely without losing version agnosticism.

We could extend the skeleton with a couple of zeros in those elements, but 
it'd need a note on the indavisability of doing that if you need BC with 4 
(the compiler would spit error about excess elements in initializer).

I'm all for a macro, maybe even a full start/end set like the 
global/ini/arg_info declarations have.  Again, there's version BC to be 
considered, but that can be solved with some #ifndefs in the skeleton...

PHP_BEGIN_FUNCTION_LIST(extname)
    PHP_FE(...)
    PHP_FE(...)
    PHP_FE(...)
PHP_END_FUNCTION_LIST(extname)

Same for the module entry....

These are all just window dressing though so unless someone else sees this 
as a worthwhile thing...*shrug*

-Sara

---

## #23866 — Michael Walter — 2006-06-02T08:39:50+00:00

URL: https://externals.io/message/23853#23866 · In reply to: #23854

At least the C++ standard guarantees that all remaining members of the
struct are initialized with their respective default value (which
would is be 0/NULL). So technically speaking, simply using {NULL} is
absolutely fine.

From a cursory glance it appears to me that it is the same with C, but
feel free to check the standard on your own ;)

Regards,
Michael


> > […]
> Your analysis is correct, however(functionally speaking) the only attribute
> that NEEDs to be explicitly set `NULL` is fname.  The rest can be garbage and
> everything will still function fine.  The second and third elements are set
> `NULL` becasue they can be safely without losing version agnosticism.
>
> We could extend the skeleton with a couple of zeros in those elements, but
> it'd need a note on the indavisability of doing that if you need BC with 4
> (the compiler would spit error about excess elements in initializer).
>
> I'm all for a macro, maybe even a full start/end set like the
> global/ini/arg_info declarations have.  Again, there's version BC to be
> considered, but that can be solved with some #ifndefs in the skeleton...
>
> PHP_BEGIN_FUNCTION_LIST(extname)
>     PHP_FE(...)
>     PHP_FE(...)
>     PHP_FE(...)
> PHP_END_FUNCTION_LIST(extname)
>
> Same for the module entry....
>
> These are all just window dressing though so unless someone else sees this
> as a worthwhile thing...*shrug*
>
> -Sara
