Directory Services

ReallocADsMem

The ReallocADsMem function resizes an existing memory block.

LPVOID ReallocADsMem(
  LPVOID pOldMem,
  DWORD cbOld,
  DWORD cbNew
);

Parameters

pOldMem
[in] Pointer to the existing memory.
cbOld
[in] Size, in bytes, of the existing memory.
cbNew
[in] Size, in bytes, of the memory to be reallocated.

Return Values

When successful, the function returns a pointer to the new allocated memory. Otherwise it returns NULL.

Remarks

If cbNew is less than cbOld, the existing memory is truncated to fit the new memory size. The following code example illustrates how to use ReallocADsMem to enlarge a string.

LPWSTR path = (LPWSTR)AllocADsMem(9*sizeof(WCHAR));
wcsncpy(path, L"WinNT://",9); 			 // Path becomes "WinNT://"
printf("path = %S\n",path);
path = (LPWSTR)ReallocADsMem(path,
					 9*sizeof(WCHAR),
					18*sizeof(WCHAR));   // Path is still "WinNT://"
if(path)
{
   wcscat(path, L"localhost",18 - wcslen(path));
   printf("path = %S\n",path); 		 // Path is "WinNT://localhost"
}
else
{
   printf("Unable to allocate additional memory.");
}

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, AllocADsMem