summaryrefslogtreecommitdiff
path: root/ext/com_dotnet/com_variant.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/com_dotnet/com_variant.c')
-rw-r--r--ext/com_dotnet/com_variant.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/ext/com_dotnet/com_variant.c b/ext/com_dotnet/com_variant.c
index f4f7d5a9dd..901b0a866a 100644
--- a/ext/com_dotnet/com_variant.c
+++ b/ext/com_dotnet/com_variant.c
@@ -96,7 +96,6 @@ bogus:
PHP_COM_DOTNET_API void php_com_variant_from_zval(VARIANT *v, zval *z, int codepage)
{
- OLECHAR *olestring;
php_com_dotnet_object *obj;
zend_uchar ztype = IS_NULL;
@@ -164,13 +163,7 @@ PHP_COM_DOTNET_API void php_com_variant_from_zval(VARIANT *v, zval *z, int codep
case IS_STRING:
V_VT(v) = VT_BSTR;
- olestring = php_com_string_to_olestring(Z_STRVAL_P(z), Z_STRLEN_P(z), codepage);
- if (CP_UTF8 == codepage) {
- V_BSTR(v) = SysAllocStringByteLen((char*)olestring, (UINT)(wcslen(olestring) * sizeof(OLECHAR)));
- } else {
- V_BSTR(v) = SysAllocStringByteLen((char*)olestring, (UINT)(Z_STRLEN_P(z) * sizeof(OLECHAR)));
- }
- efree(olestring);
+ V_BSTR(v) = php_com_string_to_bstr(Z_STR_P(z), codepage);
break;
case IS_RESOURCE:
@@ -236,12 +229,8 @@ PHP_COM_DOTNET_API int php_com_zval_from_variant(zval *z, VARIANT *v, int codepa
case VT_BSTR:
olestring = V_BSTR(v);
if (olestring) {
- size_t len;
- char *str = php_com_olestring_to_string(olestring,
- &len, codepage);
- ZVAL_STRINGL(z, str, len);
- // TODO: avoid reallocation???
- efree(str);
+ zend_string *str = php_com_bstr_to_string(olestring, codepage);
+ ZVAL_STR(z, str);
olestring = NULL;
}
break;