# zend_parse_parameters question

- Thread: https://externals.io/message/7365
- Original archive: https://news-web.php.net/php.internals/7365
- Started by unkno me on 2004-01-27T22:53:29+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

---

## #7365 — unkno me — 2004-01-27T22:53:29+00:00

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

Hi,
I am using the zend_parse_parameter function to
retrieve a string passed to my function like:

char* s, int sl;

zend_parse_parameter(ZEND_NUM_ARGS() TSRMLS_CC,"s",
       &s,&sl);

and then later I am using the memcmp function to test
2 strings like:

memcmp(key,s,sl);

but for some reason, the memcmp never return 0
indicates key and s is the same even I KNOW key and s
is indeed the same. key and s is always of the same
length. In fact, even doing a:

fprintf(stderr,"[%s %i]\n",s,sl);

yields different result for s and sl than what's
really passed to my function. Why is that? Is there a
bug in the zend_parse_paramter function that I am not
aware of? I should mention that:

1. The string is always ASCII
2. Sometimes, I do see the expected result but not all
the time. That's what makes me so confuse.

Thanks!

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

---

## #7369 — Derick Rethans — 2004-01-28T08:26:41+00:00

URL: https://externals.io/message/7365#7369 · In reply to: #7365

> I am using the zend_parse_parameter function to
> retrieve a string passed to my function like:
>
> char* s, int sl;

You need to use a long for sl here.

>
> zend_parse_parameter(ZEND_NUM_ARGS() TSRMLS_CC,"s", &s,&sl);

Shouldn't it be zend_parse_parameters (with an extra s?)

>
> and then later I am using the memcmp function to test
> 2 strings like:
>
> memcmp(key,s,sl);
>
> but for some reason, the memcmp never return 0
> indicates key and s is the same even I KNOW key and s
> is indeed the same. key and s is always of the same
> length. In fact, even doing a:
>
> fprintf(stderr,"[%s %i]\n",s,sl);
>
> yields different result for s and sl than what's
> really passed to my function. Why is that? Is there a
> bug in the zend_parse_paramter function that I am not
> aware of? I should mention that:
>
> 1. The string is always ASCII
> 2. Sometimes, I do see the expected result but not all
> the time. That's what makes me so confuse.

Might be memory curruption somewhere else, try to run with valgrind to
see if that's the case.

regards,
Derick
