void *CoTaskMemRealloc( void *pvMem, uint32 cb ) { /* * Note that we don't go through the riff-raff specified above. * We know that the allocator object is /always/ present in the * process, since we never unload it (regardless of its reference * count). Therefore, there's no point in wasting CPU cycles on it. */ if( initCount != 0 ) return IMalloc_Realloc( pTaskMalloc, pvMem, cb ); else return NULL; }
static void set_buffer(LPWSTR *buffer, LPCWSTR string) { static const WCHAR empty_string[] = {0}; IMalloc *malloc; ULONG cb; if (string == NULL) string = empty_string; CoGetMalloc(1, &malloc); cb = (strlenW(string) + 1)*sizeof(WCHAR); if (*buffer == NULL || cb > IMalloc_GetSize(malloc, *buffer)) *buffer = IMalloc_Realloc(malloc, *buffer, cb); memcpy(*buffer, string, cb); }
/*********************************************************************** * CoTaskMemRealloc [OLE32.@] * * Allocates memory using the current process memory allocator. * * PARAMS * pvOld [I] Pointer to old memory block. * size [I] Size of the new memory block. * * RETURNS * Success: Pointer to newly allocated memory block. * Failure: NULL. */ LPVOID WINAPI CoTaskMemRealloc(LPVOID pvOld, ULONG size) { return IMalloc_Realloc((LPMALLOC)&Malloc32, pvOld, size); }
/*********************************************************************** * CoTaskMemRealloc [OLE32.@] * * Allocates memory using the current process memory allocator. * * PARAMS * pvOld [I] Pointer to old memory block. * size [I] Size of the new memory block. * * RETURNS * Success: Pointer to newly allocated memory block. * Failure: NULL. */ LPVOID WINAPI CoTaskMemRealloc(LPVOID pvOld, ULONG size) { return IMalloc_Realloc(&Malloc32.IMalloc_iface, pvOld, size); }