mirror of https://github.com/FreeRDP/FreeRDP
libwinpr-handle: reduce usage of unneeded handle management functions
This commit is contained in:
parent
23e8af45f0
commit
c0160b8015
|
@ -49,7 +49,7 @@ BOOL CloseHandle(HANDLE hObject)
|
|||
|
||||
thread = (WINPR_THREAD*) Object;
|
||||
|
||||
free(thread);
|
||||
free(Object);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ BOOL CloseHandle(HANDLE hObject)
|
|||
mutex = (WINPR_MUTEX*) Object;
|
||||
|
||||
pthread_mutex_destroy(&mutex->mutex);
|
||||
winpr_Handle_Remove(Object);
|
||||
|
||||
free(Object);
|
||||
|
||||
return TRUE;
|
||||
|
@ -85,8 +85,7 @@ BOOL CloseHandle(HANDLE hObject)
|
|||
}
|
||||
}
|
||||
|
||||
winpr_Handle_Remove(Object);
|
||||
free(event);
|
||||
free(Object);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -119,7 +118,6 @@ BOOL CloseHandle(HANDLE hObject)
|
|||
#endif
|
||||
|
||||
#endif
|
||||
winpr_Handle_Remove(Object);
|
||||
free(Object);
|
||||
|
||||
return TRUE;
|
||||
|
@ -135,7 +133,7 @@ BOOL CloseHandle(HANDLE hObject)
|
|||
close(pipe->fd);
|
||||
}
|
||||
|
||||
winpr_Handle_Remove(Object);
|
||||
free(Object);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -40,9 +40,19 @@ struct winpr_handle
|
|||
};
|
||||
typedef struct winpr_handle WINPR_HANDLE;
|
||||
|
||||
WINPR_API HANDLE winpr_Handle_Insert(ULONG Type, PVOID Object);
|
||||
WINPR_API BOOL winpr_Handle_Remove(HANDLE handle);
|
||||
#define WINPR_HANDLE_SET_TYPE(_handle, _type) \
|
||||
_handle->Type = _type
|
||||
|
||||
WINPR_API BOOL winpr_Handle_GetInfo(HANDLE handle, ULONG* pType, PVOID* pObject);
|
||||
static inline BOOL winpr_Handle_GetInfo(HANDLE handle, ULONG* pType, PVOID* pObject)
|
||||
{
|
||||
WINPR_HANDLE* wHandle;
|
||||
|
||||
wHandle = (WINPR_HANDLE*) handle;
|
||||
|
||||
*pType = wHandle->Type;
|
||||
*pObject = handle;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif /* WINPR_HANDLE_PRIVATE_H */
|
||||
|
|
|
@ -28,33 +28,5 @@
|
|||
|
||||
#include "../handle/handle.h"
|
||||
|
||||
HANDLE winpr_Handle_Insert(ULONG Type, PVOID Object)
|
||||
{
|
||||
WINPR_HANDLE* wHandle;
|
||||
|
||||
wHandle = (WINPR_HANDLE*) Object;
|
||||
|
||||
wHandle->Type = Type;
|
||||
|
||||
return (HANDLE) wHandle;
|
||||
}
|
||||
|
||||
BOOL winpr_Handle_Remove(HANDLE handle)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL winpr_Handle_GetInfo(HANDLE handle, ULONG* pType, PVOID* pObject)
|
||||
{
|
||||
WINPR_HANDLE* wHandle;
|
||||
|
||||
wHandle = (WINPR_HANDLE*) handle;
|
||||
|
||||
*pType = wHandle->Type;
|
||||
*pObject = handle;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -62,11 +62,11 @@ BOOL CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpP
|
|||
pReadPipe->fd = pipe_fd[0];
|
||||
pWritePipe->fd = pipe_fd[1];
|
||||
|
||||
handle = winpr_Handle_Insert(HANDLE_TYPE_ANONYMOUS_PIPE, pReadPipe);
|
||||
*((ULONG_PTR*) hReadPipe) = (ULONG_PTR) handle;
|
||||
WINPR_HANDLE_SET_TYPE(pReadPipe, HANDLE_TYPE_ANONYMOUS_PIPE);
|
||||
*((ULONG_PTR*) hReadPipe) = (ULONG_PTR) pReadPipe;
|
||||
|
||||
handle = winpr_Handle_Insert(HANDLE_TYPE_ANONYMOUS_PIPE, pWritePipe);
|
||||
*((ULONG_PTR*) hWritePipe) = (ULONG_PTR) handle;
|
||||
WINPR_HANDLE_SET_TYPE(pWritePipe, HANDLE_TYPE_ANONYMOUS_PIPE);
|
||||
*((ULONG_PTR*) hWritePipe) = (ULONG_PTR) pWritePipe;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -80,7 +80,8 @@ HANDLE CreateEventW(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset,
|
|||
}
|
||||
#endif
|
||||
|
||||
handle = winpr_Handle_Insert(HANDLE_TYPE_EVENT, event);
|
||||
WINPR_HANDLE_SET_TYPE(event, HANDLE_TYPE_EVENT);
|
||||
handle = (HANDLE) event;
|
||||
}
|
||||
|
||||
if (!cs.LockSemaphore)
|
||||
|
@ -221,7 +222,8 @@ HANDLE CreateFileDescriptorEventW(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL
|
|||
event->pipe_fd[0] = FileDescriptor;
|
||||
event->pipe_fd[1] = -1;
|
||||
|
||||
handle = winpr_Handle_Insert(HANDLE_TYPE_EVENT, event);
|
||||
WINPR_HANDLE_SET_TYPE(event, HANDLE_TYPE_EVENT);
|
||||
handle = (HANDLE) event;
|
||||
}
|
||||
|
||||
return handle;
|
||||
|
|
|
@ -50,7 +50,8 @@ HANDLE CreateMutexW(LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner,
|
|||
{
|
||||
pthread_mutex_init(&mutex->mutex, 0);
|
||||
|
||||
handle = winpr_Handle_Insert(HANDLE_TYPE_MUTEX, mutex);
|
||||
WINPR_HANDLE_SET_TYPE(mutex, HANDLE_TYPE_MUTEX);
|
||||
handle = (HANDLE) mutex;
|
||||
|
||||
if (bInitialOwner)
|
||||
pthread_mutex_lock(&mutex->mutex);
|
||||
|
|
|
@ -73,7 +73,8 @@ HANDLE CreateSemaphoreW(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lIniti
|
|||
#endif
|
||||
}
|
||||
|
||||
handle = winpr_Handle_Insert(HANDLE_TYPE_SEMAPHORE, (PVOID) semaphore);
|
||||
WINPR_HANDLE_SET_TYPE(semaphore, HANDLE_TYPE_SEMAPHORE);
|
||||
handle = (HANDLE) semaphore;
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,8 @@ HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize
|
|||
|
||||
pthread_mutex_init(&thread->mutex, 0);
|
||||
|
||||
handle = winpr_Handle_Insert(HANDLE_TYPE_THREAD, (void*) thread);
|
||||
WINPR_HANDLE_SET_TYPE(thread, HANDLE_TYPE_THREAD);
|
||||
handle = (HANDLE) thread;
|
||||
|
||||
if (!(dwCreationFlags & CREATE_SUSPENDED))
|
||||
winpr_StartThread(thread);
|
||||
|
|
Loading…
Reference in New Issue