Commit 0448e1f7 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

qmgr: Use CRT allocation functions.

parent 7efa1498
...@@ -76,8 +76,8 @@ static ULONG WINAPI EnumBackgroundCopyFiles_Release(IEnumBackgroundCopyFiles *if ...@@ -76,8 +76,8 @@ static ULONG WINAPI EnumBackgroundCopyFiles_Release(IEnumBackgroundCopyFiles *if
{ {
for(i = 0; i < This->numFiles; i++) for(i = 0; i < This->numFiles; i++)
IBackgroundCopyFile2_Release(This->files[i]); IBackgroundCopyFile2_Release(This->files[i]);
HeapFree(GetProcessHeap(), 0, This->files); free(This->files);
HeapFree(GetProcessHeap(), 0, This); free(This);
} }
return ref; return ref;
...@@ -188,7 +188,7 @@ HRESULT EnumBackgroundCopyFilesConstructor(BackgroundCopyJobImpl *job, IEnumBack ...@@ -188,7 +188,7 @@ HRESULT EnumBackgroundCopyFilesConstructor(BackgroundCopyJobImpl *job, IEnumBack
TRACE("%p, %p)\n", job, enum_files); TRACE("%p, %p)\n", job, enum_files);
This = HeapAlloc(GetProcessHeap(), 0, sizeof *This); This = malloc(sizeof(*This));
if (!This) if (!This)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -202,12 +202,11 @@ HRESULT EnumBackgroundCopyFilesConstructor(BackgroundCopyJobImpl *job, IEnumBack ...@@ -202,12 +202,11 @@ HRESULT EnumBackgroundCopyFilesConstructor(BackgroundCopyJobImpl *job, IEnumBack
This->files = NULL; This->files = NULL;
if (This->numFiles > 0) if (This->numFiles > 0)
{ {
This->files = HeapAlloc(GetProcessHeap(), 0, This->files = malloc(This->numFiles * sizeof This->files[0]);
This->numFiles * sizeof This->files[0]);
if (!This->files) if (!This->files)
{ {
LeaveCriticalSection(&job->cs); LeaveCriticalSection(&job->cs);
HeapFree(GetProcessHeap(), 0, This); free(This);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
} }
......
...@@ -76,8 +76,8 @@ static ULONG WINAPI EnumBackgroundCopyJobs_Release(IEnumBackgroundCopyJobs *ifac ...@@ -76,8 +76,8 @@ static ULONG WINAPI EnumBackgroundCopyJobs_Release(IEnumBackgroundCopyJobs *ifac
if (ref == 0) { if (ref == 0) {
for(i = 0; i < This->numJobs; i++) for(i = 0; i < This->numJobs; i++)
IBackgroundCopyJob4_Release(This->jobs[i]); IBackgroundCopyJob4_Release(This->jobs[i]);
HeapFree(GetProcessHeap(), 0, This->jobs); free(This->jobs);
HeapFree(GetProcessHeap(), 0, This); free(This);
} }
return ref; return ref;
...@@ -182,7 +182,7 @@ HRESULT enum_copy_job_create(BackgroundCopyManagerImpl *qmgr, IEnumBackgroundCop ...@@ -182,7 +182,7 @@ HRESULT enum_copy_job_create(BackgroundCopyManagerImpl *qmgr, IEnumBackgroundCop
TRACE("%p, %p)\n", qmgr, enumjob); TRACE("%p, %p)\n", qmgr, enumjob);
This = HeapAlloc(GetProcessHeap(), 0, sizeof *This); This = malloc(sizeof(*This));
if (!This) if (!This)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
This->IEnumBackgroundCopyJobs_iface.lpVtbl = &EnumBackgroundCopyJobsVtbl; This->IEnumBackgroundCopyJobs_iface.lpVtbl = &EnumBackgroundCopyJobsVtbl;
...@@ -196,12 +196,11 @@ HRESULT enum_copy_job_create(BackgroundCopyManagerImpl *qmgr, IEnumBackgroundCop ...@@ -196,12 +196,11 @@ HRESULT enum_copy_job_create(BackgroundCopyManagerImpl *qmgr, IEnumBackgroundCop
if (0 < This->numJobs) if (0 < This->numJobs)
{ {
This->jobs = HeapAlloc(GetProcessHeap(), 0, This->jobs = malloc(This->numJobs * sizeof *This->jobs);
This->numJobs * sizeof *This->jobs);
if (!This->jobs) if (!This->jobs)
{ {
LeaveCriticalSection(&qmgr->cs); LeaveCriticalSection(&qmgr->cs);
HeapFree(GetProcessHeap(), 0, This); free(This);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
} }
......
...@@ -82,9 +82,9 @@ static ULONG WINAPI BackgroundCopyFile_Release( ...@@ -82,9 +82,9 @@ static ULONG WINAPI BackgroundCopyFile_Release(
if (ref == 0) if (ref == 0)
{ {
IBackgroundCopyJob4_Release(&file->owner->IBackgroundCopyJob4_iface); IBackgroundCopyJob4_Release(&file->owner->IBackgroundCopyJob4_iface);
HeapFree(GetProcessHeap(), 0, file->info.LocalName); free(file->info.LocalName);
HeapFree(GetProcessHeap(), 0, file->info.RemoteName); free(file->info.RemoteName);
HeapFree(GetProcessHeap(), 0, file); free(file);
} }
return ref; return ref;
...@@ -167,34 +167,29 @@ HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner, ...@@ -167,34 +167,29 @@ HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner,
TRACE("(%s, %s, %p)\n", debugstr_w(remoteName), debugstr_w(localName), file); TRACE("(%s, %s, %p)\n", debugstr_w(remoteName), debugstr_w(localName), file);
This = HeapAlloc(GetProcessHeap(), 0, sizeof *This); This = calloc(1, sizeof(*This));
if (!This) if (!This)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
This->info.RemoteName = strdupW(remoteName); This->info.RemoteName = wcsdup(remoteName);
if (!This->info.RemoteName) if (!This->info.RemoteName)
{ {
HeapFree(GetProcessHeap(), 0, This); free(This);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
This->info.LocalName = strdupW(localName); This->info.LocalName = wcsdup(localName);
if (!This->info.LocalName) if (!This->info.LocalName)
{ {
HeapFree(GetProcessHeap(), 0, This->info.RemoteName); free(This->info.RemoteName);
HeapFree(GetProcessHeap(), 0, This); free(This);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
This->IBackgroundCopyFile2_iface.lpVtbl = &BackgroundCopyFile2Vtbl; This->IBackgroundCopyFile2_iface.lpVtbl = &BackgroundCopyFile2Vtbl;
This->ref = 1; This->ref = 1;
This->fileProgress.BytesTotal = BG_SIZE_UNKNOWN; This->fileProgress.BytesTotal = BG_SIZE_UNKNOWN;
This->fileProgress.BytesTransferred = 0;
This->fileProgress.Completed = FALSE;
This->owner = owner; This->owner = owner;
This->read_size = 0;
This->tempFileName[0] = 0;
IBackgroundCopyJob4_AddRef(&owner->IBackgroundCopyJob4_iface); IBackgroundCopyJob4_AddRef(&owner->IBackgroundCopyJob4_iface);
*file = This; *file = This;
......
...@@ -99,7 +99,7 @@ static ULONG WINAPI copy_error_Release( ...@@ -99,7 +99,7 @@ static ULONG WINAPI copy_error_Release(
if (!refs) if (!refs)
{ {
if (error->file) IBackgroundCopyFile2_Release(error->file); if (error->file) IBackgroundCopyFile2_Release(error->file);
HeapFree(GetProcessHeap(), 0, error); free(error);
} }
return refs; return refs;
} }
...@@ -189,7 +189,7 @@ static HRESULT create_copy_error( ...@@ -189,7 +189,7 @@ static HRESULT create_copy_error(
TRACE("context %u code %08lx file %p\n", context, code, file); TRACE("context %u code %08lx file %p\n", context, code, file);
if (!(error = HeapAlloc(GetProcessHeap(), 0, sizeof(*error) ))) return E_OUTOFMEMORY; if (!(error = malloc(sizeof(*error) ))) return E_OUTOFMEMORY;
error->IBackgroundCopyError_iface.lpVtbl = &copy_error_vtbl; error->IBackgroundCopyError_iface.lpVtbl = &copy_error_vtbl;
error->refs = 1; error->refs = 1;
error->context = context; error->context = context;
...@@ -262,22 +262,22 @@ static ULONG WINAPI BackgroundCopyJob_Release(IBackgroundCopyJob4 *iface) ...@@ -262,22 +262,22 @@ static ULONG WINAPI BackgroundCopyJob_Release(IBackgroundCopyJob4 *iface)
DeleteCriticalSection(&job->cs); DeleteCriticalSection(&job->cs);
if (job->callback) if (job->callback)
IBackgroundCopyCallback2_Release(job->callback); IBackgroundCopyCallback2_Release(job->callback);
HeapFree(GetProcessHeap(), 0, job->displayName); free(job->displayName);
HeapFree(GetProcessHeap(), 0, job->description); free(job->description);
HeapFree(GetProcessHeap(), 0, job->http_options.headers); free(job->http_options.headers);
for (i = 0; i < BG_AUTH_TARGET_PROXY; i++) for (i = 0; i < BG_AUTH_TARGET_PROXY; i++)
{ {
for (j = 0; j < BG_AUTH_SCHEME_PASSPORT; j++) for (j = 0; j < BG_AUTH_SCHEME_PASSPORT; j++)
{ {
BG_AUTH_CREDENTIALS *cred = &job->http_options.creds[i][j]; BG_AUTH_CREDENTIALS *cred = &job->http_options.creds[i][j];
HeapFree(GetProcessHeap(), 0, cred->Credentials.Basic.UserName); free(cred->Credentials.Basic.UserName);
HeapFree(GetProcessHeap(), 0, cred->Credentials.Basic.Password); free(cred->Credentials.Basic.Password);
} }
} }
CloseHandle(job->wait); CloseHandle(job->wait);
CloseHandle(job->cancel); CloseHandle(job->cancel);
CloseHandle(job->done); CloseHandle(job->done);
HeapFree(GetProcessHeap(), 0, job); free(job);
} }
return ref; return ref;
...@@ -578,10 +578,8 @@ static HRESULT WINAPI BackgroundCopyJob_SetDescription(IBackgroundCopyJob4 *ifac ...@@ -578,10 +578,8 @@ static HRESULT WINAPI BackgroundCopyJob_SetDescription(IBackgroundCopyJob4 *ifac
} }
else else
{ {
HeapFree(GetProcessHeap(), 0, job->description); free(job->description);
if ((job->description = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR)))) if (!(job->description = wcsdup(desc)))
lstrcpyW(job->description, desc);
else
hr = E_OUTOFMEMORY; hr = E_OUTOFMEMORY;
} }
...@@ -803,13 +801,13 @@ static HRESULT WINAPI BackgroundCopyJob_SetCredentials(IBackgroundCopyJob4 *ifac ...@@ -803,13 +801,13 @@ static HRESULT WINAPI BackgroundCopyJob_SetCredentials(IBackgroundCopyJob4 *ifac
if (cred->Credentials.Basic.UserName) if (cred->Credentials.Basic.UserName)
{ {
HeapFree(GetProcessHeap(), 0, new_cred->Credentials.Basic.UserName); free(new_cred->Credentials.Basic.UserName);
new_cred->Credentials.Basic.UserName = strdupW(cred->Credentials.Basic.UserName); new_cred->Credentials.Basic.UserName = wcsdup(cred->Credentials.Basic.UserName);
} }
if (cred->Credentials.Basic.Password) if (cred->Credentials.Basic.Password)
{ {
HeapFree(GetProcessHeap(), 0, new_cred->Credentials.Basic.Password); free(new_cred->Credentials.Basic.Password);
new_cred->Credentials.Basic.Password = strdupW(cred->Credentials.Basic.Password); new_cred->Credentials.Basic.Password = wcsdup(cred->Credentials.Basic.Password);
} }
LeaveCriticalSection(&job->cs); LeaveCriticalSection(&job->cs);
...@@ -834,9 +832,9 @@ static HRESULT WINAPI BackgroundCopyJob_RemoveCredentials( ...@@ -834,9 +832,9 @@ static HRESULT WINAPI BackgroundCopyJob_RemoveCredentials(
EnterCriticalSection(&job->cs); EnterCriticalSection(&job->cs);
new_cred->Target = new_cred->Scheme = 0; new_cred->Target = new_cred->Scheme = 0;
HeapFree(GetProcessHeap(), 0, new_cred->Credentials.Basic.UserName); free(new_cred->Credentials.Basic.UserName);
new_cred->Credentials.Basic.UserName = NULL; new_cred->Credentials.Basic.UserName = NULL;
HeapFree(GetProcessHeap(), 0, new_cred->Credentials.Basic.Password); free(new_cred->Credentials.Basic.Password);
new_cred->Credentials.Basic.Password = NULL; new_cred->Credentials.Basic.Password = NULL;
LeaveCriticalSection(&job->cs); LeaveCriticalSection(&job->cs);
...@@ -1047,18 +1045,18 @@ static HRESULT WINAPI http_options_SetCustomHeaders( ...@@ -1047,18 +1045,18 @@ static HRESULT WINAPI http_options_SetCustomHeaders(
if (RequestHeaders) if (RequestHeaders)
{ {
WCHAR *headers = strdupW(RequestHeaders); WCHAR *headers = wcsdup(RequestHeaders);
if (!headers) if (!headers)
{ {
LeaveCriticalSection(&job->cs); LeaveCriticalSection(&job->cs);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
HeapFree(GetProcessHeap(), 0, job->http_options.headers); free(job->http_options.headers);
job->http_options.headers = headers; job->http_options.headers = headers;
} }
else else
{ {
HeapFree(GetProcessHeap(), 0, job->http_options.headers); free(job->http_options.headers);
job->http_options.headers = NULL; job->http_options.headers = NULL;
} }
...@@ -1140,7 +1138,7 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID ...@@ -1140,7 +1138,7 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID
TRACE("(%s,%d,%p)\n", debugstr_w(displayName), type, job); TRACE("(%s,%d,%p)\n", debugstr_w(displayName), type, job);
This = HeapAlloc(GetProcessHeap(), 0, sizeof *This); This = malloc(sizeof(*This));
if (!This) if (!This)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -1152,12 +1150,12 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID ...@@ -1152,12 +1150,12 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID
This->ref = 1; This->ref = 1;
This->type = type; This->type = type;
This->displayName = strdupW(displayName); This->displayName = wcsdup(displayName);
if (!This->displayName) if (!This->displayName)
{ {
This->cs.DebugInfo->Spare[0] = 0; This->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&This->cs); DeleteCriticalSection(&This->cs);
HeapFree(GetProcessHeap(), 0, This); free(This);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
...@@ -1166,8 +1164,8 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID ...@@ -1166,8 +1164,8 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID
{ {
This->cs.DebugInfo->Spare[0] = 0; This->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&This->cs); DeleteCriticalSection(&This->cs);
HeapFree(GetProcessHeap(), 0, This->displayName); free(This->displayName);
HeapFree(GetProcessHeap(), 0, This); free(This);
return hr; return hr;
} }
*job_id = This->jobId; *job_id = This->jobId;
......
...@@ -115,13 +115,6 @@ BOOL processFile(BackgroundCopyFileImpl *file, BackgroundCopyJobImpl *job) DECLS ...@@ -115,13 +115,6 @@ BOOL processFile(BackgroundCopyFileImpl *file, BackgroundCopyJobImpl *job) DECLS
BOOL transitionJobState(BackgroundCopyJobImpl *job, BG_JOB_STATE from, BG_JOB_STATE to) DECLSPEC_HIDDEN; BOOL transitionJobState(BackgroundCopyJobImpl *job, BG_JOB_STATE from, BG_JOB_STATE to) DECLSPEC_HIDDEN;
/* Little helper functions */ /* Little helper functions */
static inline WCHAR *strdupW(const WCHAR *src)
{
WCHAR *dst = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(src) + 1) * sizeof(WCHAR));
if (dst) lstrcpyW(dst, src);
return dst;
}
static inline WCHAR *co_strdupW(const WCHAR *src) static inline WCHAR *co_strdupW(const WCHAR *src)
{ {
WCHAR *dst = CoTaskMemAlloc((lstrlenW(src) + 1) * sizeof(WCHAR)); WCHAR *dst = CoTaskMemAlloc((lstrlenW(src) + 1) * sizeof(WCHAR));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment