From: Michael Wallner Date: Mon, 8 Aug 2005 12:15:52 +0000 (+0000) Subject: - be smart about internal/user zvals, though it's not actually used X-Git-Tag: RELEASE_0_12_0~40 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=5aa47bb3226e35928025f06f0b550582f69608bd;p=m6w6%2Fext-http - be smart about internal/user zvals, though it's not actually used --- diff --git a/missing.c b/missing.c index d60d55d..328096c 100644 --- a/missing.c +++ b/missing.c @@ -119,11 +119,11 @@ int zend_declare_class_constant_string(zend_class_entry *ce, char *name, size_t int zend_declare_class_constant_stringl(zend_class_entry *ce, char *name, size_t name_length, char *value, size_t value_length TSRMLS_DC) { zval *constant = new_class_constant_zval(ce); - Z_TYPE_P(constant) = IS_STRING; - Z_STRLEN_P(constant) = value_length; - Z_STRVAL_P(constant) = malloc(value_length + 1); - memcpy(Z_STRVAL_P(constant), value, value_length); - Z_STRVAL_P(constant)[value_length] = '\0'; + if (ce->type & ZEND_INTERNAL_CLASS) { + ZVAL_STRINGL(constant, zend_strndup(value, value_length), value_length, 0); + } else { + ZVAL_STRINGL(constant, value, value_length, 1); + } return zend_declare_class_constant(ce, name, name_length, constant TSRMLS_CC); } #endif diff --git a/missing.h b/missing.h index 822c3b3..7186818 100644 --- a/missing.h +++ b/missing.h @@ -28,6 +28,7 @@ extern int zend_declare_property_bool(zend_class_entry *ce, char *name, int name extern void zend_update_property_bool(zend_class_entry *scope, zval *object, char *name, int name_length, long value TSRMLS_DC); #endif +#if (PHP_MAJOR_VERSION >= 5) int zend_declare_class_constant(zend_class_entry *ce, char *name, size_t name_length, zval *value TSRMLS_DC); int zend_declare_class_constant_null(zend_class_entry *ce, char *name, size_t name_length TSRMLS_DC); int zend_declare_class_constant_long(zend_class_entry *ce, char *name, size_t name_length, long value TSRMLS_DC); @@ -37,6 +38,8 @@ int zend_declare_class_constant_string(zend_class_entry *ce, char *name, size_t int zend_declare_class_constant_stringl(zend_class_entry *ce, char *name, size_t name_length, char *value, size_t value_length TSRMLS_DC); #endif +#endif + /* * Local variables: * tab-width: 4