MarshalStringAlloc.cpp 804 B

1234567891011121314151617181920212223242526272829303132
  1. #include "il2cpp-config.h"
  2. #if !IL2CPP_USE_GENERIC_COM
  3. #include "os/MarshalStringAlloc.h"
  4. #include "WindowsHeaders.h"
  5. namespace il2cpp
  6. {
  7. namespace os
  8. {
  9. il2cpp_hresult_t MarshalStringAlloc::AllocateBStringLength(const Il2CppChar* text, int32_t length, Il2CppChar** bstr)
  10. {
  11. IL2CPP_ASSERT(bstr);
  12. *bstr = ::SysAllocStringLen(text, length);
  13. return *bstr ? IL2CPP_S_OK : IL2CPP_E_OUTOFMEMORY;
  14. }
  15. il2cpp_hresult_t MarshalStringAlloc::GetBStringLength(const Il2CppChar* bstr, int32_t* length)
  16. {
  17. IL2CPP_ASSERT(length);
  18. *length = ::SysStringLen((BSTR)bstr);
  19. return IL2CPP_S_OK;
  20. }
  21. il2cpp_hresult_t MarshalStringAlloc::FreeBString(Il2CppChar* bstr)
  22. {
  23. ::SysFreeString((BSTR)bstr);
  24. return IL2CPP_S_OK;
  25. }
  26. }
  27. }
  28. #endif