Skip to content

Commit 43cff80

Browse files
committed
Zend: Make zend_strnlen available for use outside zend_compile
1 parent 32cdd33 commit 43cff80

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

Zend/zend_compile.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,14 +1499,6 @@ ZEND_API zend_string *zend_mangle_property_name(const char *src1, size_t src1_le
14991499
}
15001500
/* }}} */
15011501

1502-
static zend_always_inline size_t zend_strnlen(const char* s, size_t maxlen) /* {{{ */
1503-
{
1504-
size_t len = 0;
1505-
while (*s++ && maxlen--) len++;
1506-
return len;
1507-
}
1508-
/* }}} */
1509-
15101502
ZEND_API zend_result zend_unmangle_property_name_ex(const zend_string *name, const char **class_name, const char **prop_name, size_t *prop_len) /* {{{ */
15111503
{
15121504
size_t class_name_len;

Zend/zend_operators.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,16 @@ zend_memnrstr(const char *haystack, const char *needle, size_t needle_len, const
264264
}
265265
}
266266

267+
static zend_always_inline size_t zend_strnlen(const char* s, size_t maxlen)
268+
{
269+
#if defined(HAVE_STRNLEN)
270+
return strnlen(s, maxlen);
271+
#else
272+
const char *p = memchr(s, '\0', maxlen);
273+
return p ? p-s : maxlen;
274+
#endif
275+
}
276+
267277
ZEND_API zend_result ZEND_FASTCALL increment_function(zval *op1);
268278
ZEND_API zend_result ZEND_FASTCALL decrement_function(zval *op2);
269279

0 commit comments

Comments
 (0)