- be smart about internal/user zvals, though it's not actually used
[m6w6/ext-http] / missing.c
index aefbdb9f08674d59571b7600e9015f6cb17baff8..328096c8a38ef427938f10767ae74fd46dc672fd 100644 (file)
--- a/missing.c
+++ b/missing.c
@@ -71,6 +71,8 @@ void zend_update_property_bool(zend_class_entry *scope, zval *object, char *name
 
 #endif
 
+#if (PHP_MAJOR_VERSION >= 5)
+
 static inline zval *new_class_constant_zval(zend_class_entry *ce)
 {
        zval *z;
@@ -117,14 +119,14 @@ 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
 
 /*
  * Local variables: