rrichards Tue Feb 7 11:52:45 2006 UTC
Modified files:
/php-src/ext/com_dotnet com_saproxy.c com_handlers.c com_iterator.c
php_com_dotnet_internal.h
Log:
modify get_iterator calls for engine change
fix mem leak with iterators
fix object casting for edge case
http://cvs.php.net/viewcvs.cgi/php-src/ext/com_dotnet/com_saproxy.c?r1=1.17&r2=1.18&diff_format=u
Index: php-src/ext/com_dotnet/com_saproxy.c
diff -u php-src/ext/com_dotnet/com_saproxy.c:1.17
php-src/ext/com_dotnet/com_saproxy.c:1.18
--- php-src/ext/com_dotnet/com_saproxy.c:1.17 Sun Jan 1 13:09:48 2006
+++ php-src/ext/com_dotnet/com_saproxy.c Tue Feb 7 11:52:45 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: com_saproxy.c,v 1.17 2006/01/01 13:09:48 sniper Exp $ */
+/* $Id: com_saproxy.c,v 1.18 2006/02/07 11:52:45 rrichards Exp $ */
/* This module implements a SafeArray proxy which is used internally
* by the engine when resolving multi-dimensional array accesses on
@@ -554,12 +554,16 @@
};
-zend_object_iterator *php_com_saproxy_iter_get(zend_class_entry *ce, zval
*object TSRMLS_DC)
+zend_object_iterator *php_com_saproxy_iter_get(zend_class_entry *ce, zval
*object, int by_ref TSRMLS_DC)
{
php_com_saproxy *proxy = SA_FETCH(object);
php_com_saproxy_iter *I;
int i;
+ if (by_ref) {
+ zend_error(E_ERROR, "An iterator cannot be used with foreach by
reference");
+ }
+
I = ecalloc(1, sizeof(*I));
I->iter.funcs = &saproxy_iter_funcs;
I->iter.data = I;
http://cvs.php.net/viewcvs.cgi/php-src/ext/com_dotnet/com_handlers.c?r1=1.35&r2=1.36&diff_format=u
Index: php-src/ext/com_dotnet/com_handlers.c
diff -u php-src/ext/com_dotnet/com_handlers.c:1.35
php-src/ext/com_dotnet/com_handlers.c:1.36
--- php-src/ext/com_dotnet/com_handlers.c:1.35 Sat Feb 4 10:59:18 2006
+++ php-src/ext/com_dotnet/com_handlers.c Tue Feb 7 11:52:45 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: com_handlers.c,v 1.35 2006/02/04 10:59:18 rrichards Exp $ */
+/* $Id: com_handlers.c,v 1.36 2006/02/07 11:52:45 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -499,7 +499,7 @@
VariantInit(&v);
if (V_VT(&obj->v) == VT_DISPATCH) {
- if (FAILURE == php_com_do_invoke_by_id(obj, DISPID_VALUE,
+ if (SUCCESS != php_com_do_invoke_by_id(obj, DISPID_VALUE,
DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, 0,
NULL, 1 TSRMLS_CC)) {
VariantCopy(&v, &obj->v);
}
http://cvs.php.net/viewcvs.cgi/php-src/ext/com_dotnet/com_iterator.c?r1=1.10&r2=1.11&diff_format=u
Index: php-src/ext/com_dotnet/com_iterator.c
diff -u php-src/ext/com_dotnet/com_iterator.c:1.10
php-src/ext/com_dotnet/com_iterator.c:1.11
--- php-src/ext/com_dotnet/com_iterator.c:1.10 Sun Jan 1 13:09:48 2006
+++ php-src/ext/com_dotnet/com_iterator.c Tue Feb 7 11:52:45 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: com_iterator.c,v 1.10 2006/01/01 13:09:48 sniper Exp $ */
+/* $Id: com_iterator.c,v 1.11 2006/02/07 11:52:45 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -38,6 +38,7 @@
VARIANT safe_array;
VARTYPE sa_type;
LONG sa_max;
+ zval *zdata;
};
static void com_iter_dtor(zend_object_iterator *iter TSRMLS_DC)
@@ -49,6 +50,9 @@
}
VariantClear(&I->v);
VariantClear(&I->safe_array);
+ if (I->zdata) {
+ zval_ptr_dtor((zval**)&I->zdata);
+ }
efree(I);
}
@@ -56,32 +60,18 @@
{
struct php_com_iterator *I = (struct php_com_iterator*)iter->data;
- if (I->key == (ulong)-1) {
- return FAILURE;
+ if (I->zdata) {
+ return SUCCESS;
}
- return SUCCESS;
+
+ return FAILURE;
}
static void com_iter_get_data(zend_object_iterator *iter, zval ***data
TSRMLS_DC)
{
struct php_com_iterator *I = (struct php_com_iterator*)iter->data;
- zval **ptr_ptr;
- zval *ptr;
-
- /* sanity */
- if (I->key == (ulong)-1) {
- *data = NULL;
- return;
- }
-
- MAKE_STD_ZVAL(ptr);
- php_com_zval_from_variant(ptr, &I->v, I->code_page TSRMLS_CC);
- /* php_com_wrap_variant(ptr, &I->v, I->code_page TSRMLS_CC); */
- ptr_ptr = emalloc(sizeof(*ptr_ptr));
- *ptr_ptr = ptr;
- *data = ptr_ptr;
- return;
+ *data = &I->zdata;
}
static int com_iter_get_key(zend_object_iterator *iter, char **str_key, uint
*str_key_len,
@@ -100,15 +90,20 @@
{
struct php_com_iterator *I = (struct php_com_iterator*)iter->data;
unsigned long n_fetched;
+ zval *ptr;
/* release current cached element */
VariantClear(&I->v);
+ if (I->zdata) {
+ zval_ptr_dtor((zval**)&I->zdata);
+ I->zdata = NULL;
+ }
+
if (I->ev) {
/* Get the next element */
if (SUCCEEDED(IEnumVARIANT_Next(I->ev, 1, &I->v, &n_fetched))
&& n_fetched > 0) {
I->key++;
- return SUCCESS;
} else {
/* indicate that there are no more items */
I->key = (ulong)-1;
@@ -121,13 +116,17 @@
return FAILURE;
}
I->key++;
- if (php_com_safearray_get_elem(&I->safe_array, &I->v,
(LONG)I->key TSRMLS_CC)) {
- return SUCCESS;
- } else {
+ if (php_com_safearray_get_elem(&I->safe_array, &I->v,
(LONG)I->key TSRMLS_CC) == 0) {
I->key = (ulong)-1;
return FAILURE;
}
}
+
+ MAKE_STD_ZVAL(ptr);
+ php_com_zval_from_variant(ptr, &I->v, I->code_page TSRMLS_CC);
+ /* php_com_wrap_variant(ptr, &I->v, I->code_page TSRMLS_CC); */
+ I->zdata = ptr;
+ return SUCCESS;
}
@@ -140,7 +139,7 @@
NULL
};
-zend_object_iterator *php_com_iter_get(zend_class_entry *ce, zval *object
TSRMLS_DC)
+zend_object_iterator *php_com_iter_get(zend_class_entry *ce, zval *object, int
by_ref TSRMLS_DC)
{
php_com_dotnet_object *obj;
struct php_com_iterator *I;
@@ -148,6 +147,11 @@
DISPPARAMS dp;
VARIANT v;
unsigned long n_fetched;
+ zval *ptr;
+
+ if (by_ref) {
+ zend_error(E_ERROR, "An iterator cannot be used with foreach by
reference");
+ }
obj = CDNO_FETCH(object);
@@ -163,6 +167,7 @@
I->iter.funcs = &com_iter_funcs;
I->iter.data = I;
I->code_page = obj->code_page;
+ I->zdata = NULL;
VariantInit(&I->safe_array);
VariantInit(&I->v);
@@ -189,6 +194,9 @@
/* pre-fetch the element */
if (php_com_safearray_get_elem(&I->safe_array, &I->v, bound
TSRMLS_CC)) {
I->key = bound;
+ MAKE_STD_ZVAL(ptr);
+ php_com_zval_from_variant(ptr, &I->v, I->code_page
TSRMLS_CC);
+ I->zdata = ptr;
} else {
I->key = (ulong)-1;
}
@@ -220,6 +228,9 @@
if (SUCCEEDED(IEnumVARIANT_Next(I->ev, 1, &I->v, &n_fetched))
&& n_fetched > 0) {
/* indicate that we have element 0 */
I->key = 0;
+ MAKE_STD_ZVAL(ptr);
+ php_com_zval_from_variant(ptr, &I->v, I->code_page
TSRMLS_CC);
+ I->zdata = ptr;
} else {
/* indicate that there are no more items */
I->key = (ulong)-1;
http://cvs.php.net/viewcvs.cgi/php-src/ext/com_dotnet/php_com_dotnet_internal.h?r1=1.17&r2=1.18&diff_format=u
Index: php-src/ext/com_dotnet/php_com_dotnet_internal.h
diff -u php-src/ext/com_dotnet/php_com_dotnet_internal.h:1.17
php-src/ext/com_dotnet/php_com_dotnet_internal.h:1.18
--- php-src/ext/com_dotnet/php_com_dotnet_internal.h:1.17 Thu Jan 26
11:18:09 2006
+++ php-src/ext/com_dotnet/php_com_dotnet_internal.h Tue Feb 7 11:52:45 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_com_dotnet_internal.h,v 1.17 2006/01/26 11:18:09 rrichards Exp $ */
+/* $Id: php_com_dotnet_internal.h,v 1.18 2006/02/07 11:52:45 rrichards Exp $ */
#ifndef PHP_COM_DOTNET_INTERNAL_H
#define PHP_COM_DOTNET_INTERNAL_H
@@ -82,7 +82,7 @@
void php_com_object_enable_event_sink(php_com_dotnet_object *obj, int enable
TSRMLS_DC);
/* com_saproxy.c */
-zend_object_iterator *php_com_saproxy_iter_get(zend_class_entry *ce, zval
*object TSRMLS_DC);
+zend_object_iterator *php_com_saproxy_iter_get(zend_class_entry *ce, zval
*object, int by_ref TSRMLS_DC);
int php_com_saproxy_create(zval *com_object, zval *proxy_out, zval *index
TSRMLS_DC);
/* com_olechar.c */
@@ -177,7 +177,7 @@
int php_com_process_typeinfo(ITypeInfo *typeinfo, HashTable *id_to_name, int
printdef, GUID *guid, int codepage TSRMLS_DC);
/* com_iterator.c */
-zend_object_iterator *php_com_iter_get(zend_class_entry *ce, zval *object
TSRMLS_DC);
+zend_object_iterator *php_com_iter_get(zend_class_entry *ce, zval *object, int
by_ref TSRMLS_DC);
#endif
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php