struct vlc_entry_data
{
- vlc_thread_t handle;
- void * (*func) (void *);
- void * data;
+ void * (*func) (void *);
+ void * data;
};
static unsigned __stdcall vlc_entry (void *p)
* memory leaks and the signal functions not working (see Microsoft
* Knowledge Base, article 104641) */
HANDLE hThread;
- vlc_thread_t th = malloc (sizeof (*th));
-
- if (th == NULL)
- return ENOMEM;
struct vlc_entry_data *entry_data = malloc (sizeof (*entry_data));
if (entry_data == NULL)
- {
- free (th);
return ENOMEM;
- }
- entry_data->handle = th;
entry_data->func = entry;
entry_data->data = data;
th->cancel_event = CreateEvent (NULL, FALSE, FALSE, NULL);
if (th->cancel_event == NULL)
{
- free(th);
free (entry_data);
return errno;
}
/* Thread closes the handle when exiting, duplicate it here
* to be on the safe side when joining. */
if (!DuplicateHandle (GetCurrentProcess (), hThread,
- GetCurrentProcess (), &th->handle, 0, FALSE,
+ GetCurrentProcess (), p_handle, 0, FALSE,
DUPLICATE_SAME_ACCESS))
{
CloseHandle (hThread);
- free (th);
free (entry_data);
return ENOMEM;
}
ResumeThread (hThread);
if (priority)
SetThreadPriority (hThread, priority);
-
- *p_handle = th;
return 0;
}
- free (th);
return errno;
}
{
do
vlc_testcancel ();
- while (WaitForSingleObjectEx (handle->handle, INFINITE, TRUE)
+ while (WaitForSingleObjectEx (handle, INFINITE, TRUE)
== WAIT_IO_COMPLETION);
- CloseHandle (handle->handle);
+ CloseHandle (handle);
assert (result == NULL); /* <- FIXME if ever needed */
#ifdef UNDER_CE
CloseHandle (handle->cancel_event);
#endif
- free (handle);
}
void vlc_cancel (vlc_thread_t thread_id)
{
#ifndef UNDER_CE
- QueueUserAPC (vlc_cancel_self, thread_id->handle, 0);
+ QueueUserAPC (vlc_cancel_self, thread_id, 0);
#else
SetEvent (thread_id->cancel_event);
#endif