utf8_helper.cpp
changeset 40 dfb59114debe
parent 39 6fc5cc7a167c
child 42 7d1be3be0c07
     1.1 --- a/utf8_helper.cpp	Sun May 31 19:31:19 2015 +0200
     1.2 +++ b/utf8_helper.cpp	Sun May 31 20:04:38 2015 +0200
     1.3 @@ -73,24 +73,24 @@
     1.4              return result;
     1.5          }
     1.6  
     1.7 -        _bstr_t utf16_bstr(string str)
     1.8 +        BSTR utf16_bstr(string str)
     1.9          {
    1.10              wstring wstr = utf16_string(str);
    1.11 -            return _bstr_t(wstr.c_str());
    1.12 +            return _bstr_t(wstr.c_str()).Detach();
    1.13          }
    1.14  
    1.15 -        CComSafeArray<BSTR> string_array(const ::stringlist_t *stringlist)
    1.16 +        LPSAFEARRAY string_array(const ::stringlist_t *stringlist)
    1.17          {
    1.18              int len = ::stringlist_length(stringlist);
    1.19  
    1.20              if (len = 0)
    1.21 -                return CComSafeArray<BSTR>((ULONG)0);
    1.22 +                return NULL;
    1.23  
    1.24              CComSafeArray<BSTR> sa_string_list((LONG) len);
    1.25              LONG n = 0;
    1.26              for (const ::stringlist_t *k = stringlist; k && k->value; k = k->next) {
    1.27                  if (k->value) {
    1.28 -                    HRESULT _result = sa_string_list.SetAt(n, utf16_bstr(k->value).Detach(), false);
    1.29 +                    HRESULT _result = sa_string_list.SetAt(n, utf16_bstr(k->value), false);
    1.30                      assert(_result == S_OK);
    1.31                      if (_result == E_OUTOFMEMORY)
    1.32                          throw std::bad_alloc();
    1.33 @@ -98,7 +98,7 @@
    1.34                  }
    1.35              }
    1.36  
    1.37 -            return sa_string_list;
    1.38 +            return sa_string_list.Detach();
    1.39          }
    1.40  
    1.41          ::stringlist_t * new_stringlist(const SAFEARRAY * safearray)