SysReAllocStringLen Function

Creates a new BSTR containing a specified number of characters from an old BSTR, and frees the old BSTR.

INT SysReAllocStringLen(  
  BSTR  *pbstr,  
  const OLECHAR  *psz, 
  unsigned int  cch  


Pointer to a variable containing a BSTR.


Pointer to string from which to copy cch number of characters, or NULL to keep the string uninitialized.


Number of characters to copy from psz. A null character is placed afterward, allocating a total of cch plus one characters.




The string is reallocated successfully.


Insufficient memory exists.

Allocates a new string, copies cchcharacters from the passed string into it, and then appends a null character. Frees the BSTR referenced currently by pbstr, and resets pbstr to point to the new BSTR. If psz is Null, a string of length cch is allocated but not initialized.

The psz string can contain embedded null characters and does not need to end with a Null.

If this function is passed a NULL pointer, there will be an access violation and the program will crash. It is your responsibility to protect this function against NULL pointers.