mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-08-26 08:31:39 +00:00
[SDL2] pointer boolean (#8523)
This commit is contained in:
@@ -89,7 +89,7 @@ static SDL_cond *SDL_CreateCond_cv(void)
|
||||
|
||||
/* Relies on CONDITION_VARIABLE_INIT == 0. */
|
||||
cond = (SDL_cond_cv *)SDL_calloc(1, sizeof(*cond));
|
||||
if (cond == NULL) {
|
||||
if (!cond) {
|
||||
SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ static SDL_cond *SDL_CreateCond_cv(void)
|
||||
|
||||
static void SDL_DestroyCond_cv(SDL_cond *cond)
|
||||
{
|
||||
if (cond != NULL) {
|
||||
if (cond) {
|
||||
/* There are no kernel allocated resources */
|
||||
SDL_free(cond);
|
||||
}
|
||||
@@ -107,7 +107,7 @@ static void SDL_DestroyCond_cv(SDL_cond *cond)
|
||||
static int SDL_CondSignal_cv(SDL_cond *_cond)
|
||||
{
|
||||
SDL_cond_cv *cond = (SDL_cond_cv *)_cond;
|
||||
if (cond == NULL) {
|
||||
if (!cond) {
|
||||
return SDL_InvalidParamError("cond");
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ static int SDL_CondSignal_cv(SDL_cond *_cond)
|
||||
static int SDL_CondBroadcast_cv(SDL_cond *_cond)
|
||||
{
|
||||
SDL_cond_cv *cond = (SDL_cond_cv *)_cond;
|
||||
if (cond == NULL) {
|
||||
if (!cond) {
|
||||
return SDL_InvalidParamError("cond");
|
||||
}
|
||||
|
||||
@@ -134,10 +134,10 @@ static int SDL_CondWaitTimeout_cv(SDL_cond *_cond, SDL_mutex *_mutex, Uint32 ms)
|
||||
DWORD timeout;
|
||||
int ret;
|
||||
|
||||
if (cond == NULL) {
|
||||
if (!cond) {
|
||||
return SDL_InvalidParamError("cond");
|
||||
}
|
||||
if (_mutex == NULL) {
|
||||
if (!_mutex) {
|
||||
return SDL_InvalidParamError("mutex");
|
||||
}
|
||||
|
||||
@@ -220,14 +220,14 @@ static const SDL_cond_impl_t SDL_cond_impl_generic = {
|
||||
|
||||
SDL_cond *SDL_CreateCond(void)
|
||||
{
|
||||
if (SDL_cond_impl_active.Create == NULL) {
|
||||
if (!SDL_cond_impl_active.Create) {
|
||||
/* Default to generic implementation, works with all mutex implementations */
|
||||
const SDL_cond_impl_t *impl = &SDL_cond_impl_generic;
|
||||
|
||||
if (SDL_mutex_impl_active.Type == SDL_MUTEX_INVALID) {
|
||||
/* The mutex implementation isn't decided yet, trigger it */
|
||||
SDL_mutex *mutex = SDL_CreateMutex();
|
||||
if (mutex == NULL) {
|
||||
if (!mutex) {
|
||||
return NULL;
|
||||
}
|
||||
SDL_DestroyMutex(mutex);
|
||||
|
||||
@@ -62,7 +62,7 @@ static SDL_mutex *SDL_CreateMutex_srw(void)
|
||||
|
||||
/* Relies on SRWLOCK_INIT == 0. */
|
||||
mutex = (SDL_mutex_srw *)SDL_calloc(1, sizeof(*mutex));
|
||||
if (mutex == NULL) {
|
||||
if (!mutex) {
|
||||
SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ static SDL_mutex *SDL_CreateMutex_cs(void)
|
||||
|
||||
/* Allocate mutex memory */
|
||||
mutex = (SDL_mutex_cs *)SDL_malloc(sizeof(*mutex));
|
||||
if (mutex != NULL) {
|
||||
if (mutex) {
|
||||
/* Initialize */
|
||||
/* On SMP systems, a non-zero spin count generally helps performance */
|
||||
#if __WINRT__
|
||||
@@ -221,7 +221,7 @@ static const SDL_mutex_impl_t SDL_mutex_impl_cs = {
|
||||
|
||||
SDL_mutex *SDL_CreateMutex(void)
|
||||
{
|
||||
if (SDL_mutex_impl_active.Create == NULL) {
|
||||
if (!SDL_mutex_impl_active.Create) {
|
||||
/* Default to fallback implementation */
|
||||
const SDL_mutex_impl_t *impl = &SDL_mutex_impl_cs;
|
||||
|
||||
@@ -260,7 +260,7 @@ void SDL_DestroyMutex(SDL_mutex *mutex)
|
||||
|
||||
int SDL_LockMutex(SDL_mutex *mutex)
|
||||
{
|
||||
if (mutex == NULL) {
|
||||
if (!mutex) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ int SDL_LockMutex(SDL_mutex *mutex)
|
||||
|
||||
int SDL_TryLockMutex(SDL_mutex *mutex)
|
||||
{
|
||||
if (mutex == NULL) {
|
||||
if (!mutex) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex)
|
||||
|
||||
int SDL_UnlockMutex(SDL_mutex *mutex)
|
||||
{
|
||||
if (mutex == NULL) {
|
||||
if (!mutex) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ static SDL_sem *SDL_CreateSemaphore_atom(Uint32 initial_value)
|
||||
SDL_sem_atom *sem;
|
||||
|
||||
sem = (SDL_sem_atom *)SDL_malloc(sizeof(*sem));
|
||||
if (sem != NULL) {
|
||||
if (sem) {
|
||||
sem->count = initial_value;
|
||||
} else {
|
||||
SDL_OutOfMemory();
|
||||
@@ -107,7 +107,7 @@ static SDL_sem *SDL_CreateSemaphore_atom(Uint32 initial_value)
|
||||
|
||||
static void SDL_DestroySemaphore_atom(SDL_sem *sem)
|
||||
{
|
||||
if (sem != NULL) {
|
||||
if (sem) {
|
||||
SDL_free(sem);
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,7 @@ static int SDL_SemTryWait_atom(SDL_sem *_sem)
|
||||
SDL_sem_atom *sem = (SDL_sem_atom *)_sem;
|
||||
LONG count;
|
||||
|
||||
if (sem == NULL) {
|
||||
if (!sem) {
|
||||
return SDL_InvalidParamError("sem");
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ static int SDL_SemWait_atom(SDL_sem *_sem)
|
||||
SDL_sem_atom *sem = (SDL_sem_atom *)_sem;
|
||||
LONG count;
|
||||
|
||||
if (sem == NULL) {
|
||||
if (!sem) {
|
||||
return SDL_InvalidParamError("sem");
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ static int SDL_SemWaitTimeout_atom(SDL_sem *_sem, Uint32 timeout)
|
||||
return SDL_SemWait_atom(_sem);
|
||||
}
|
||||
|
||||
if (sem == NULL) {
|
||||
if (!sem) {
|
||||
return SDL_InvalidParamError("sem");
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ static Uint32 SDL_SemValue_atom(SDL_sem *_sem)
|
||||
{
|
||||
SDL_sem_atom *sem = (SDL_sem_atom *)_sem;
|
||||
|
||||
if (sem == NULL) {
|
||||
if (!sem) {
|
||||
SDL_InvalidParamError("sem");
|
||||
return 0;
|
||||
}
|
||||
@@ -223,7 +223,7 @@ static int SDL_SemPost_atom(SDL_sem *_sem)
|
||||
{
|
||||
SDL_sem_atom *sem = (SDL_sem_atom *)_sem;
|
||||
|
||||
if (sem == NULL) {
|
||||
if (!sem) {
|
||||
return SDL_InvalidParamError("sem");
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ static SDL_sem *SDL_CreateSemaphore_kern(Uint32 initial_value)
|
||||
|
||||
/* Allocate sem memory */
|
||||
sem = (SDL_sem_kern *)SDL_malloc(sizeof(*sem));
|
||||
if (sem != NULL) {
|
||||
if (sem) {
|
||||
/* Create the semaphore, with max value 32K */
|
||||
#if __WINRT__
|
||||
sem->id = CreateSemaphoreEx(NULL, initial_value, 32 * 1024, NULL, 0, SEMAPHORE_ALL_ACCESS);
|
||||
@@ -284,7 +284,7 @@ static SDL_sem *SDL_CreateSemaphore_kern(Uint32 initial_value)
|
||||
static void SDL_DestroySemaphore_kern(SDL_sem *_sem)
|
||||
{
|
||||
SDL_sem_kern *sem = (SDL_sem_kern *)_sem;
|
||||
if (sem != NULL) {
|
||||
if (sem) {
|
||||
if (sem->id) {
|
||||
CloseHandle(sem->id);
|
||||
sem->id = 0;
|
||||
@@ -299,7 +299,7 @@ static int SDL_SemWaitTimeout_kern(SDL_sem *_sem, Uint32 timeout)
|
||||
int retval;
|
||||
DWORD dwMilliseconds;
|
||||
|
||||
if (sem == NULL) {
|
||||
if (!sem) {
|
||||
return SDL_InvalidParamError("sem");
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ static int SDL_SemWait_kern(SDL_sem *sem)
|
||||
static Uint32 SDL_SemValue_kern(SDL_sem *_sem)
|
||||
{
|
||||
SDL_sem_kern *sem = (SDL_sem_kern *)_sem;
|
||||
if (sem == NULL) {
|
||||
if (!sem) {
|
||||
SDL_InvalidParamError("sem");
|
||||
return 0;
|
||||
}
|
||||
@@ -347,7 +347,7 @@ static Uint32 SDL_SemValue_kern(SDL_sem *_sem)
|
||||
static int SDL_SemPost_kern(SDL_sem *_sem)
|
||||
{
|
||||
SDL_sem_kern *sem = (SDL_sem_kern *)_sem;
|
||||
if (sem == NULL) {
|
||||
if (!sem) {
|
||||
return SDL_InvalidParamError("sem");
|
||||
}
|
||||
/* Increase the counter in the first place, because
|
||||
@@ -379,7 +379,7 @@ static const SDL_sem_impl_t SDL_sem_impl_kern = {
|
||||
|
||||
SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
|
||||
{
|
||||
if (SDL_sem_impl_active.Create == NULL) {
|
||||
if (!SDL_sem_impl_active.Create) {
|
||||
/* Default to fallback implementation */
|
||||
const SDL_sem_impl_t *impl = &SDL_sem_impl_kern;
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ static DWORD RunThread(void *data)
|
||||
SDL_Thread *thread = (SDL_Thread *)data;
|
||||
pfnSDL_CurrentEndThread pfnEndThread = (pfnSDL_CurrentEndThread)thread->endfunc;
|
||||
SDL_RunThread(thread);
|
||||
if (pfnEndThread != NULL) {
|
||||
if (pfnEndThread) {
|
||||
pfnEndThread(0);
|
||||
}
|
||||
return 0;
|
||||
@@ -98,7 +98,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread)
|
||||
RunThreadViaCreateThread,
|
||||
thread, flags, &threadid);
|
||||
}
|
||||
if (thread->handle == NULL) {
|
||||
if (!thread->handle) {
|
||||
return SDL_SetError("Not enough resources to create thread");
|
||||
}
|
||||
return 0;
|
||||
@@ -118,7 +118,7 @@ typedef HRESULT(WINAPI *pfnSetThreadDescription)(HANDLE, PCWSTR);
|
||||
|
||||
void SDL_SYS_SetupThread(const char *name)
|
||||
{
|
||||
if (name != NULL) {
|
||||
if (name) {
|
||||
#ifndef __WINRT__ /* !!! FIXME: There's no LoadLibrary() in WinRT; don't know if SetThreadDescription is available there at all at the moment. */
|
||||
static pfnSetThreadDescription pSetThreadDescription = NULL;
|
||||
static HMODULE kernel32 = NULL;
|
||||
@@ -130,7 +130,7 @@ void SDL_SYS_SetupThread(const char *name)
|
||||
}
|
||||
}
|
||||
|
||||
if (pSetThreadDescription != NULL) {
|
||||
if (pSetThreadDescription) {
|
||||
WCHAR *strw = WIN_UTF8ToStringW(name);
|
||||
if (strw) {
|
||||
pSetThreadDescription(GetCurrentThread(), strw);
|
||||
|
||||
Reference in New Issue
Block a user