Directory Services

ReallocADsStr

The ReallocADsStr function makes a copy of an existing string.

BOOL ReallocADsStr(
  LPWSTR* ppStr,
  LPWSTR pStr
);

Parameters

ppStr
[out] Pointer to the destination null-terminated Unicode string.
pStr
[in] The source null-terminated Unicode string.

Return Values

The function returns TRUE if successful, otherwise FALSE is returned.

Remarks

Strings allocated by ReallocADsStr must be freed by FreeADsStr.

The following code example creates a deep copy of a string.

LPWSTR szSrc = L"This is a string.";
LPWSTR szDest = NULL;

if (ReallocADsStr(&szDest,szSrc) {
	printf("Copy of %S is  %S\", szSrc, szDest);
}
else {
	printf("Out of Memory.");
}

FreeADsStr(szDest);

The source string memory block is not freed when the copy is created; the application must free memory when it is no longer required. The application should initialize the ppStr destination pointer to NULL before calling this function if it does not point to an existing string. Otherwise, ReallocADsStr assumes that the destination pointer contains a valid string buffer address and attempts to free the memory block before copying the source string.

Requirements

Client: Included in Windows XP and Windows 2000 Professional.
Server: Included in Windows Server 2003 and Windows 2000 Server.
Redistributable: Requires Active Directory Client Extension on Windows NT 4.0 SP6a and Windows 95/98/Me.
Header: Declared in Adshlp.h.
Library: Use ActiveDS.lib.

See Also

ADSI Functions, AllocADsStr, FreeADsStr