internal static SafeBSTRHandle Allocate(String src, uint len) { SafeBSTRHandle bstr = SysAllocStringLen(src, len); bstr.Initialize(len * sizeof(char)); return(bstr); }
internal static SafeBSTRHandle Allocate(string src, uint len) { SafeBSTRHandle handle = SysAllocStringLen(src, len); handle.Initialize((ulong)(len * 2)); return(handle); }
internal static SafeBSTRHandle Allocate(IntPtr src, uint lenInBytes) { SafeBSTRHandle bstr = Interop.OleAut32.SysAllocStringLen(src, lenInBytes / sizeof(char)); bstr.Initialize(lenInBytes); return(bstr); }
internal static SafeBSTRHandle Allocate(string src, uint len) { SafeBSTRHandle safeBstrHandle = SafeBSTRHandle.SysAllocStringLen(src, len); long num = (long)(len * 2U); safeBstrHandle.Initialize((ulong)num); return(safeBstrHandle); }
internal static SafeBSTRHandle Allocate(string src, uint lenInChars) { SafeBSTRHandle bstr = Interop.OleAut32.SysAllocStringLen(src, lenInChars); if (bstr.IsInvalid) // SysAllocStringLen returns a NULL ptr when there's insufficient memory { throw new OutOfMemoryException(); } bstr.Initialize(lenInChars * sizeof(char)); return(bstr); }
internal static SafeBSTRHandle Allocate(IntPtr src, uint lenInBytes) { Debug.Assert(lenInBytes % sizeof(char) == 0); SafeBSTRHandle bstr = Interop.OleAut32.SysAllocStringLen(src, lenInBytes / sizeof(char)); if (bstr.IsInvalid) // SysAllocStringLen returns a NULL ptr when there's insufficient memory { throw new OutOfMemoryException(); } bstr.Initialize(lenInBytes); return(bstr); }