Platform SDK: Active Directory, ADSI, and Directory Services

ReallocADsMem

The ReallocADsMem function resizes an existing block of memroy.

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

Parameters

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

Return Values

When successful, the function returns a pointer to the newly 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 snippet illustrates how to use ReallocADsMem to enlarge a string.

LPWSTR path = (LPWSTR)AllocADsMem(9*sizeof(WCHAR));
wcscpy(path, L"WinNT://");                 // path becomes "WinNT://"
printf("path = %$\n",path);
path = (LPWSTR)ReallocADsMem(path,
                       9*sizeof(WCHAR),
                      18*sizeof(WCHAR));   // path is still "WinNT://"
wcscat(path, L"localhost");
printf("path = %S\n",path);             // path is "WinNT://localhost"

Requirements

  Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with DSClient).
  Windows 95/98: Requires Windows 95 or later (with DSClient).
  Header: Declared in Adshlp.h.
  Library: Included as a resource in ActiveDs.dll.

See Also

ADSI Functions, AllocADsMem