helpers.cpp revision c58f1213e628a545081c70e26c6b67a841cff880
/** @file
*
* COM helper functions for XPCOM
*/
/*
* Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#include <nsMemory.h>
//
// OLE Automation string APIs
//
// Note: on Windows, every BSTR stores its length in the
// byte just before the pointer you get. If we do it like this,
// the caller cannot just use nsMemory::Free() on our strings.
// Therefore we'll try to implement it differently and hope that
// we don't run into problems.
/**
* Copies a string into a new memory block including the terminating UCS2 NULL
* @param sz source string to copy
* @returns BSTR new string buffer
*/
{
if (!sz)
{
return NULL;
}
}
/**
* Copies len OLECHARs of a string into a new memory block and
* adds a terminating UCS2 NULL
* @param psz source string to copy
* @param len length of the source string in bytes
* @returns BSTR new string buffer
*/
{
unsigned int *newBuffer;
char *newString;
if (!newBuffer)
{
return NULL;
}
if (psz)
{
}
// make sure there is a trailing UCS2 NULL
}
/**
* Create a BSTR from the OLECHAR string with a given length in UCS2 characters
* @param pch pointer to the source string
* @param cch length of the source string in UCS2 characters
* @returns BSTR new string buffer
*/
{
unsigned int bufferSize;
unsigned int *newBuffer;
// add the trailing UCS2 NULL
if (!newBuffer)
{
return NULL;
}
// copy the string, a NULL input string is allowed
if (pch)
{
} else
{
}
// make sure there is a trailing UCS2 NULL
}
/**
* Frees the memory associated with the BSTR given
* @param bstr source string to free
*/
{
if (bstr)
{
}
}
/**
* Reallocates a string by freeing the old string and copying
* a new string into a new buffer.
* @param pbstr old string to free
* @param psz source string to copy into the new string
* @returns success indicator
*/
{
if (!pbstr)
{
return 0;
}
return 1;
}
/**
* Changes the length of a previous created BSTR
* @param pbstr string to change the length of
* @param psz source string to copy into the adjusted pbstr
* @param cch length of the source string in UCS2 characters
* @returns int success indicator
*/
{
if (SysStringLen(*pbstr) > 0)
{
unsigned int newByteLen;
unsigned int *newBuffer;
newByteLen + sizeof(OLECHAR));
if (psz)
{
}
} else
{
// allocate a new string
}
return 1;
}
/**
* Returns the string length in bytes without the terminator
* @returns unsigned int length in bytes
* @param bstr source string
*/
{
}
/**
* Returns the string length in OLECHARs without the terminator
* @returns unsigned int length in OLECHARs
* @param bstr source string
*/
{
return RTUtf16Len(bstr);
}