Logo Search packages:      
Sourcecode: virtualbox-ose version File versions  Download package

BSTR SysAllocStringByteLen ( char *  psz,
unsigned int  len 

Copies len OLECHARs of a string into a new memory block and adds a terminating UCS2 NULL

psz source string to copy
len length of the source string in bytes
BSTR new string buffer

Definition at line 56 of file helpers.cpp.

References NULL, and OLECHAR.

    unsigned int *newBuffer;
    char *newString;

    newBuffer = (unsigned int*)nsMemory::Alloc(len + sizeof(OLECHAR));
    if (!newBuffer)
        return NULL;
    if (psz)
        memcpy(newBuffer, psz, len);
    // make sure there is a trailing UCS2 NULL
    newString = (char*)newBuffer;
    newString[len] = '\0';
    newString[len + 1] = '\0';
    return (BSTR)newString;

Generated by  Doxygen 1.6.0   Back to index