Permalink
Browse files

use ZVAL_ZVAL instead of retaining render_flags and extensions.

  • Loading branch information...
1 parent 498992e commit 46a92dc317d70c5a9c1ab06d793957d4e90b6235 @chobie committed Jan 8, 2012
Showing with 11 additions and 13 deletions.
  1. +5 −6 src/php_sundown.c
  2. +6 −7 src/sundown_markdown.c
View
11 src/php_sundown.c
@@ -288,7 +288,7 @@ static void sundown__render(SundownRendererType render_type, INTERNAL_FUNCTION_P
setup Sundown extension */
PHP_METHOD(sundown, __construct)
{
- zval *extensions = NULL;
+ zval *extensions ,*c_extensions = NULL;
char *buffer;
int buffer_len = 0;
@@ -302,9 +302,10 @@ PHP_METHOD(sundown, __construct)
MAKE_STD_ZVAL(extensions);
array_init(extensions);
} else {
- Z_ADDREF_P(extensions);
+ ALLOC_INIT_ZVAL(c_extensions);
+ ZVAL_ZVAL(c_extensions,extensions,1,0);
}
- add_property_zval_ex(getThis(),"extensions",sizeof("extensions"),extensions TSRMLS_CC);
+ add_property_zval_ex(getThis(),"extensions",sizeof("extensions"),c_extensions TSRMLS_CC);
}
/* }}} */
@@ -315,9 +316,7 @@ PHP_METHOD(sundown, __destruct)
zval *extensions;
extensions = zend_read_property(sundown_class_entry, getThis(),"extensions",sizeof("extensions")-1, 0 TSRMLS_CC);
- if(extensions != NULL && Z_TYPE_P(extensions) != IS_NULL) {
- zval_ptr_dtor(&extensions);
- }
+ zval_ptr_dtor(&extensions);
}
/* }}} */
View
13 src/sundown_markdown.c
@@ -310,7 +310,7 @@ zend_object_value php_sundown_markdown_new(zend_class_entry *ce TSRMLS_DC)
PHP_METHOD(sundown_markdown, __construct)
{
zval *render;
- zval *extensions = NULL;
+ zval *extensions, *c_extensions = NULL;
zend_class_entry **ce;
php_sundown_markdown_t *object = (php_sundown_markdown_t *) zend_object_store_get_object(getThis() TSRMLS_CC);
@@ -350,9 +350,10 @@ PHP_METHOD(sundown_markdown, __construct)
MAKE_STD_ZVAL(extensions);
array_init(extensions);
} else {
- Z_ADDREF_P(extensions);
- }
- add_property_zval_ex(getThis(),"extensions",sizeof("extensions"),extensions TSRMLS_CC);
+ ALLOC_INIT_ZVAL(c_extensions);
+ ZVAL_ZVAL(c_extensions,extensions,1,0);
+ }
+ add_property_zval_ex(getThis(),"extensions",sizeof("extensions"),c_extensions TSRMLS_CC);
}
/* }}} */
@@ -364,9 +365,7 @@ PHP_METHOD(sundown_markdown, __destruct)
zval *extensions;
extensions = zend_read_property(sundown_markdown_class_entry, getThis(),"extensions",sizeof("extensions")-1, 0 TSRMLS_CC);
- if(extensions != NULL && Z_TYPE_P(extensions) != IS_NULL) {
- zval_ptr_dtor(&extensions);
- }
+ zval_ptr_dtor(&extensions);
}
/* }}} */

0 comments on commit 46a92dc

Please sign in to comment.