Commit 4ee48f26 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

schedsvc: Use standard C functions for memory allocation in atsvc.c.

parent caf39cd1
...@@ -354,15 +354,15 @@ static DWORD load_unicode_strings(const char *data, DWORD limit, struct job_t *j ...@@ -354,15 +354,15 @@ static DWORD load_unicode_strings(const char *data, DWORD limit, struct job_t *j
switch (i) switch (i)
{ {
case 0: case 0:
job->info.Command = heap_strdupW((const WCHAR *)data); job->info.Command = wcsdup((const WCHAR *)data);
break; break;
case 1: case 1:
job->params = heap_strdupW((const WCHAR *)data); job->params = wcsdup((const WCHAR *)data);
break; break;
case 2: case 2:
job->curdir = heap_strdupW((const WCHAR *)data); job->curdir = wcsdup((const WCHAR *)data);
break; break;
default: default:
...@@ -504,7 +504,7 @@ static BOOL load_job_data(const char *data, DWORD size, struct job_t *info) ...@@ -504,7 +504,7 @@ static BOOL load_job_data(const char *data, DWORD size, struct job_t *info)
return FALSE; return FALSE;
} }
info->trigger = heap_alloc(info->trigger_count * sizeof(info->trigger[0])); info->trigger = malloc(info->trigger_count * sizeof(info->trigger[0]));
if (!info->trigger) if (!info->trigger)
{ {
TRACE("not enough memory for trigger data\n"); TRACE("not enough memory for trigger data\n");
...@@ -596,24 +596,24 @@ static BOOL load_job(const WCHAR *name, struct job_t *info) ...@@ -596,24 +596,24 @@ static BOOL load_job(const WCHAR *name, struct job_t *info)
static void free_job_info(AT_ENUM *info) static void free_job_info(AT_ENUM *info)
{ {
heap_free(info->Command); free(info->Command);
} }
static void free_job(struct job_t *job) static void free_job(struct job_t *job)
{ {
free_job_info(&job->info); free_job_info(&job->info);
heap_free(job->name); free(job->name);
heap_free(job->params); free(job->params);
heap_free(job->curdir); free(job->curdir);
heap_free(job->trigger); free(job->trigger);
heap_free(job); free(job);
} }
void add_job(const WCHAR *name) void add_job(const WCHAR *name)
{ {
struct job_t *job; struct job_t *job;
job = heap_alloc_zero(sizeof(*job)); job = calloc(1, sizeof(*job));
if (!job) return; if (!job) return;
if (!load_job(name, job)) if (!load_job(name, job))
...@@ -623,7 +623,7 @@ void add_job(const WCHAR *name) ...@@ -623,7 +623,7 @@ void add_job(const WCHAR *name)
} }
EnterCriticalSection(&at_job_list_section); EnterCriticalSection(&at_job_list_section);
job->name = heap_strdupW(name); job->name = wcsdup(name);
job->info.JobId = current_jobid++; job->info.JobId = current_jobid++;
list_add_tail(&at_job_list, &job->entry); list_add_tail(&at_job_list, &job->entry);
LeaveCriticalSection(&at_job_list_section); LeaveCriticalSection(&at_job_list_section);
...@@ -920,7 +920,7 @@ void update_process_status(DWORD pid) ...@@ -920,7 +920,7 @@ void update_process_status(DWORD pid)
{ {
CloseHandle(runjob->process); CloseHandle(runjob->process);
list_remove(&runjob->entry); list_remove(&runjob->entry);
heap_free(runjob); free(runjob);
job->data.exit_code = exit_code; job->data.exit_code = exit_code;
job->data.status = SCHED_S_TASK_TERMINATED; job->data.status = SCHED_S_TASK_TERMINATED;
...@@ -969,7 +969,7 @@ void check_task_state(void) ...@@ -969,7 +969,7 @@ void check_task_state(void)
if (job->instance_count) if (job->instance_count)
FIXME("process %s is already running\n", debugstr_w(job->info.Command)); FIXME("process %s is already running\n", debugstr_w(job->info.Command));
runjob = heap_alloc(sizeof(*runjob)); runjob = malloc(sizeof(*runjob));
if (runjob) if (runjob)
{ {
static WCHAR winsta0[] = { 'W','i','n','S','t','a','0',0 }; static WCHAR winsta0[] = { 'W','i','n','S','t','a','0',0 };
...@@ -1179,9 +1179,9 @@ static void free_container(AT_ENUM_CONTAINER *container) ...@@ -1179,9 +1179,9 @@ static void free_container(AT_ENUM_CONTAINER *container)
DWORD i; DWORD i;
for (i = 0; i < container->EntriesRead; i++) for (i = 0; i < container->EntriesRead; i++)
heap_free(container->Buffer[i].Command); free(container->Buffer[i].Command);
heap_free(container->Buffer); free(container->Buffer);
} }
DWORD __cdecl NetrJobEnum(ATSVC_HANDLE server_name, AT_ENUM_CONTAINER *container, DWORD __cdecl NetrJobEnum(ATSVC_HANDLE server_name, AT_ENUM_CONTAINER *container,
...@@ -1197,7 +1197,7 @@ DWORD __cdecl NetrJobEnum(ATSVC_HANDLE server_name, AT_ENUM_CONTAINER *container ...@@ -1197,7 +1197,7 @@ DWORD __cdecl NetrJobEnum(ATSVC_HANDLE server_name, AT_ENUM_CONTAINER *container
container->EntriesRead = 0; container->EntriesRead = 0;
allocated = 64; allocated = 64;
container->Buffer = heap_alloc(allocated * sizeof(AT_ENUM)); container->Buffer = malloc(allocated * sizeof(AT_ENUM));
if (!container->Buffer) return ERROR_NOT_ENOUGH_MEMORY; if (!container->Buffer) return ERROR_NOT_ENOUGH_MEMORY;
EnterCriticalSection(&at_job_list_section); EnterCriticalSection(&at_job_list_section);
...@@ -1215,7 +1215,7 @@ DWORD __cdecl NetrJobEnum(ATSVC_HANDLE server_name, AT_ENUM_CONTAINER *container ...@@ -1215,7 +1215,7 @@ DWORD __cdecl NetrJobEnum(ATSVC_HANDLE server_name, AT_ENUM_CONTAINER *container
AT_ENUM *new_buffer; AT_ENUM *new_buffer;
allocated *= 2; allocated *= 2;
new_buffer = heap_realloc(container->Buffer, allocated * sizeof(AT_ENUM)); new_buffer = realloc(container->Buffer, allocated * sizeof(AT_ENUM));
if (!new_buffer) if (!new_buffer)
{ {
free_container(container); free_container(container);
...@@ -1226,7 +1226,7 @@ DWORD __cdecl NetrJobEnum(ATSVC_HANDLE server_name, AT_ENUM_CONTAINER *container ...@@ -1226,7 +1226,7 @@ DWORD __cdecl NetrJobEnum(ATSVC_HANDLE server_name, AT_ENUM_CONTAINER *container
} }
container->Buffer[container->EntriesRead] = job->info; container->Buffer[container->EntriesRead] = job->info;
container->Buffer[container->EntriesRead].Command = heap_strdupW(job->info.Command); container->Buffer[container->EntriesRead].Command = wcsdup(job->info.Command);
container->EntriesRead++; container->EntriesRead++;
} }
...@@ -1249,7 +1249,7 @@ DWORD __cdecl NetrJobGetInfo(ATSVC_HANDLE server_name, DWORD jobid, AT_INFO **in ...@@ -1249,7 +1249,7 @@ DWORD __cdecl NetrJobGetInfo(ATSVC_HANDLE server_name, DWORD jobid, AT_INFO **in
job = find_job(jobid, NULL, NULL); job = find_job(jobid, NULL, NULL);
if (job) if (job)
{ {
AT_INFO *info_ret = heap_alloc(sizeof(*info_ret)); AT_INFO *info_ret = malloc(sizeof(*info_ret));
if (!info_ret) if (!info_ret)
ret = ERROR_NOT_ENOUGH_MEMORY; ret = ERROR_NOT_ENOUGH_MEMORY;
else else
...@@ -1258,7 +1258,7 @@ DWORD __cdecl NetrJobGetInfo(ATSVC_HANDLE server_name, DWORD jobid, AT_INFO **in ...@@ -1258,7 +1258,7 @@ DWORD __cdecl NetrJobGetInfo(ATSVC_HANDLE server_name, DWORD jobid, AT_INFO **in
info_ret->DaysOfMonth = job->info.DaysOfMonth; info_ret->DaysOfMonth = job->info.DaysOfMonth;
info_ret->DaysOfWeek = job->info.DaysOfWeek; info_ret->DaysOfWeek = job->info.DaysOfWeek;
info_ret->Flags = job->info.Flags; info_ret->Flags = job->info.Flags;
info_ret->Command = heap_strdupW(job->info.Command); info_ret->Command = wcsdup(job->info.Command);
*info = info_ret; *info = info_ret;
ret = ERROR_SUCCESS; ret = ERROR_SUCCESS;
} }
......
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