Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/qmgr/enum_files.c | 11 +++++----- dlls/qmgr/enum_jobs.c | 11 +++++----- dlls/qmgr/file.c | 23 ++++++++----------- dlls/qmgr/job.c | 50 ++++++++++++++++++++---------------------- dlls/qmgr/qmgr.h | 7 ------ 5 files changed, 43 insertions(+), 59 deletions(-)
diff --git a/dlls/qmgr/enum_files.c b/dlls/qmgr/enum_files.c index 92834c6bd3b..a7a26da60c9 100644 --- a/dlls/qmgr/enum_files.c +++ b/dlls/qmgr/enum_files.c @@ -76,8 +76,8 @@ static ULONG WINAPI EnumBackgroundCopyFiles_Release(IEnumBackgroundCopyFiles *if { for(i = 0; i < This->numFiles; i++) IBackgroundCopyFile2_Release(This->files[i]); - HeapFree(GetProcessHeap(), 0, This->files); - HeapFree(GetProcessHeap(), 0, This); + free(This->files); + free(This); }
return ref; @@ -188,7 +188,7 @@ HRESULT EnumBackgroundCopyFilesConstructor(BackgroundCopyJobImpl *job, IEnumBack
TRACE("%p, %p)\n", job, enum_files);
- This = HeapAlloc(GetProcessHeap(), 0, sizeof *This); + This = malloc(sizeof(*This)); if (!This) return E_OUTOFMEMORY;
@@ -202,12 +202,11 @@ HRESULT EnumBackgroundCopyFilesConstructor(BackgroundCopyJobImpl *job, IEnumBack This->files = NULL; if (This->numFiles > 0) { - This->files = HeapAlloc(GetProcessHeap(), 0, - This->numFiles * sizeof This->files[0]); + This->files = malloc(This->numFiles * sizeof This->files[0]); if (!This->files) { LeaveCriticalSection(&job->cs); - HeapFree(GetProcessHeap(), 0, This); + free(This); return E_OUTOFMEMORY; } } diff --git a/dlls/qmgr/enum_jobs.c b/dlls/qmgr/enum_jobs.c index 00d8ea52b4f..d31303ab1fc 100644 --- a/dlls/qmgr/enum_jobs.c +++ b/dlls/qmgr/enum_jobs.c @@ -76,8 +76,8 @@ static ULONG WINAPI EnumBackgroundCopyJobs_Release(IEnumBackgroundCopyJobs *ifac if (ref == 0) { for(i = 0; i < This->numJobs; i++) IBackgroundCopyJob4_Release(This->jobs[i]); - HeapFree(GetProcessHeap(), 0, This->jobs); - HeapFree(GetProcessHeap(), 0, This); + free(This->jobs); + free(This); }
return ref; @@ -182,7 +182,7 @@ HRESULT enum_copy_job_create(BackgroundCopyManagerImpl *qmgr, IEnumBackgroundCop
TRACE("%p, %p)\n", qmgr, enumjob);
- This = HeapAlloc(GetProcessHeap(), 0, sizeof *This); + This = malloc(sizeof(*This)); if (!This) return E_OUTOFMEMORY; This->IEnumBackgroundCopyJobs_iface.lpVtbl = &EnumBackgroundCopyJobsVtbl; @@ -196,12 +196,11 @@ HRESULT enum_copy_job_create(BackgroundCopyManagerImpl *qmgr, IEnumBackgroundCop
if (0 < This->numJobs) { - This->jobs = HeapAlloc(GetProcessHeap(), 0, - This->numJobs * sizeof *This->jobs); + This->jobs = malloc(This->numJobs * sizeof *This->jobs); if (!This->jobs) { LeaveCriticalSection(&qmgr->cs); - HeapFree(GetProcessHeap(), 0, This); + free(This); return E_OUTOFMEMORY; } } diff --git a/dlls/qmgr/file.c b/dlls/qmgr/file.c index 339354d59c0..c82344a51a8 100644 --- a/dlls/qmgr/file.c +++ b/dlls/qmgr/file.c @@ -82,9 +82,9 @@ static ULONG WINAPI BackgroundCopyFile_Release( if (ref == 0) { IBackgroundCopyJob4_Release(&file->owner->IBackgroundCopyJob4_iface); - HeapFree(GetProcessHeap(), 0, file->info.LocalName); - HeapFree(GetProcessHeap(), 0, file->info.RemoteName); - HeapFree(GetProcessHeap(), 0, file); + free(file->info.LocalName); + free(file->info.RemoteName); + free(file); }
return ref; @@ -167,34 +167,29 @@ HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner,
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) return E_OUTOFMEMORY;
- This->info.RemoteName = strdupW(remoteName); + This->info.RemoteName = wcsdup(remoteName); if (!This->info.RemoteName) { - HeapFree(GetProcessHeap(), 0, This); + free(This); return E_OUTOFMEMORY; }
- This->info.LocalName = strdupW(localName); + This->info.LocalName = wcsdup(localName); if (!This->info.LocalName) { - HeapFree(GetProcessHeap(), 0, This->info.RemoteName); - HeapFree(GetProcessHeap(), 0, This); + free(This->info.RemoteName); + free(This); return E_OUTOFMEMORY; }
This->IBackgroundCopyFile2_iface.lpVtbl = &BackgroundCopyFile2Vtbl; This->ref = 1; - This->fileProgress.BytesTotal = BG_SIZE_UNKNOWN; - This->fileProgress.BytesTransferred = 0; - This->fileProgress.Completed = FALSE; This->owner = owner; - This->read_size = 0; - This->tempFileName[0] = 0; IBackgroundCopyJob4_AddRef(&owner->IBackgroundCopyJob4_iface);
*file = This; diff --git a/dlls/qmgr/job.c b/dlls/qmgr/job.c index 2b8572465ad..233d894b3ea 100644 --- a/dlls/qmgr/job.c +++ b/dlls/qmgr/job.c @@ -99,7 +99,7 @@ static ULONG WINAPI copy_error_Release( if (!refs) { if (error->file) IBackgroundCopyFile2_Release(error->file); - HeapFree(GetProcessHeap(), 0, error); + free(error); } return refs; } @@ -189,7 +189,7 @@ static HRESULT create_copy_error(
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 = ©_error_vtbl; error->refs = 1; error->context = context; @@ -262,22 +262,22 @@ static ULONG WINAPI BackgroundCopyJob_Release(IBackgroundCopyJob4 *iface) DeleteCriticalSection(&job->cs); if (job->callback) IBackgroundCopyCallback2_Release(job->callback); - HeapFree(GetProcessHeap(), 0, job->displayName); - HeapFree(GetProcessHeap(), 0, job->description); - HeapFree(GetProcessHeap(), 0, job->http_options.headers); + free(job->displayName); + free(job->description); + free(job->http_options.headers); for (i = 0; i < BG_AUTH_TARGET_PROXY; i++) { for (j = 0; j < BG_AUTH_SCHEME_PASSPORT; j++) { BG_AUTH_CREDENTIALS *cred = &job->http_options.creds[i][j]; - HeapFree(GetProcessHeap(), 0, cred->Credentials.Basic.UserName); - HeapFree(GetProcessHeap(), 0, cred->Credentials.Basic.Password); + free(cred->Credentials.Basic.UserName); + free(cred->Credentials.Basic.Password); } } CloseHandle(job->wait); CloseHandle(job->cancel); CloseHandle(job->done); - HeapFree(GetProcessHeap(), 0, job); + free(job); }
return ref; @@ -578,10 +578,8 @@ static HRESULT WINAPI BackgroundCopyJob_SetDescription(IBackgroundCopyJob4 *ifac } else { - HeapFree(GetProcessHeap(), 0, job->description); - if ((job->description = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR)))) - lstrcpyW(job->description, desc); - else + free(job->description); + if (!(job->description = wcsdup(desc))) hr = E_OUTOFMEMORY; }
@@ -803,13 +801,13 @@ static HRESULT WINAPI BackgroundCopyJob_SetCredentials(IBackgroundCopyJob4 *ifac
if (cred->Credentials.Basic.UserName) { - HeapFree(GetProcessHeap(), 0, new_cred->Credentials.Basic.UserName); - new_cred->Credentials.Basic.UserName = strdupW(cred->Credentials.Basic.UserName); + free(new_cred->Credentials.Basic.UserName); + new_cred->Credentials.Basic.UserName = wcsdup(cred->Credentials.Basic.UserName); } if (cred->Credentials.Basic.Password) { - HeapFree(GetProcessHeap(), 0, new_cred->Credentials.Basic.Password); - new_cred->Credentials.Basic.Password = strdupW(cred->Credentials.Basic.Password); + free(new_cred->Credentials.Basic.Password); + new_cred->Credentials.Basic.Password = wcsdup(cred->Credentials.Basic.Password); }
LeaveCriticalSection(&job->cs); @@ -834,9 +832,9 @@ static HRESULT WINAPI BackgroundCopyJob_RemoveCredentials( EnterCriticalSection(&job->cs);
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; - HeapFree(GetProcessHeap(), 0, new_cred->Credentials.Basic.Password); + free(new_cred->Credentials.Basic.Password); new_cred->Credentials.Basic.Password = NULL;
LeaveCriticalSection(&job->cs); @@ -1047,18 +1045,18 @@ static HRESULT WINAPI http_options_SetCustomHeaders(
if (RequestHeaders) { - WCHAR *headers = strdupW(RequestHeaders); + WCHAR *headers = wcsdup(RequestHeaders); if (!headers) { LeaveCriticalSection(&job->cs); return E_OUTOFMEMORY; } - HeapFree(GetProcessHeap(), 0, job->http_options.headers); + free(job->http_options.headers); job->http_options.headers = headers; } else { - HeapFree(GetProcessHeap(), 0, job->http_options.headers); + free(job->http_options.headers); job->http_options.headers = NULL; }
@@ -1140,7 +1138,7 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID
TRACE("(%s,%d,%p)\n", debugstr_w(displayName), type, job);
- This = HeapAlloc(GetProcessHeap(), 0, sizeof *This); + This = malloc(sizeof(*This)); if (!This) return E_OUTOFMEMORY;
@@ -1152,12 +1150,12 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID This->ref = 1; This->type = type;
- This->displayName = strdupW(displayName); + This->displayName = wcsdup(displayName); if (!This->displayName) { This->cs.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&This->cs); - HeapFree(GetProcessHeap(), 0, This); + free(This); return E_OUTOFMEMORY; }
@@ -1166,8 +1164,8 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID { This->cs.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&This->cs); - HeapFree(GetProcessHeap(), 0, This->displayName); - HeapFree(GetProcessHeap(), 0, This); + free(This->displayName); + free(This); return hr; } *job_id = This->jobId; diff --git a/dlls/qmgr/qmgr.h b/dlls/qmgr/qmgr.h index de808049ea3..8d9ccae73ff 100644 --- a/dlls/qmgr/qmgr.h +++ b/dlls/qmgr/qmgr.h @@ -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;
/* 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) { WCHAR *dst = CoTaskMemAlloc((lstrlenW(src) + 1) * sizeof(WCHAR));