Use SDL_ prefixed versions of C library functions.
FIXME: Change #include <stdlib.h> to #include "SDL_stdlib.h" Change #include <string.h> to #include "SDL_string.h" Make sure nothing else broke because of this... --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401340
This commit is contained in:
parent
00f6d8e5e3
commit
5d53175e4d
212 changed files with 1840 additions and 1884 deletions
|
@ -99,16 +99,16 @@ static void SDL_AddThread(SDL_Thread *thread)
|
|||
SDL_numthreads, SDL_maxthreads);
|
||||
#endif
|
||||
if ( SDL_numthreads == SDL_maxthreads ) {
|
||||
threads=(SDL_Thread **)malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)*
|
||||
threads=(SDL_Thread **)SDL_malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)*
|
||||
(sizeof *threads));
|
||||
if ( threads == NULL ) {
|
||||
SDL_OutOfMemory();
|
||||
goto done;
|
||||
}
|
||||
memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads));
|
||||
SDL_memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads));
|
||||
SDL_maxthreads += ARRAY_CHUNKSIZE;
|
||||
if ( SDL_Threads ) {
|
||||
free(SDL_Threads);
|
||||
SDL_free(SDL_Threads);
|
||||
}
|
||||
SDL_Threads = threads;
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ static void SDL_DelThread(SDL_Thread *thread)
|
|||
}
|
||||
} else {
|
||||
SDL_maxthreads = 0;
|
||||
free(SDL_Threads);
|
||||
SDL_free(SDL_Threads);
|
||||
SDL_Threads = NULL;
|
||||
}
|
||||
#ifdef DEBUG_THREADS
|
||||
|
@ -223,19 +223,19 @@ DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data)
|
|||
int ret;
|
||||
|
||||
/* Allocate memory for the thread info structure */
|
||||
thread = (SDL_Thread *)malloc(sizeof(*thread));
|
||||
thread = (SDL_Thread *)SDL_malloc(sizeof(*thread));
|
||||
if ( thread == NULL ) {
|
||||
SDL_OutOfMemory();
|
||||
return(NULL);
|
||||
}
|
||||
memset(thread, 0, (sizeof *thread));
|
||||
SDL_memset(thread, 0, (sizeof *thread));
|
||||
thread->status = -1;
|
||||
|
||||
/* Set up the arguments for the thread */
|
||||
args = (thread_args *)malloc(sizeof(*args));
|
||||
args = (thread_args *)SDL_malloc(sizeof(*args));
|
||||
if ( args == NULL ) {
|
||||
SDL_OutOfMemory();
|
||||
free(thread);
|
||||
SDL_free(thread);
|
||||
return(NULL);
|
||||
}
|
||||
args->func = fn;
|
||||
|
@ -243,8 +243,8 @@ DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data)
|
|||
args->info = thread;
|
||||
args->wait = SDL_CreateSemaphore(0);
|
||||
if ( args->wait == NULL ) {
|
||||
free(thread);
|
||||
free(args);
|
||||
SDL_free(thread);
|
||||
SDL_free(args);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -263,11 +263,11 @@ DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data)
|
|||
} else {
|
||||
/* Oops, failed. Gotta free everything */
|
||||
SDL_DelThread(thread);
|
||||
free(thread);
|
||||
SDL_free(thread);
|
||||
thread = NULL;
|
||||
}
|
||||
SDL_DestroySemaphore(args->wait);
|
||||
free(args);
|
||||
SDL_free(args);
|
||||
|
||||
/* Everything is running now */
|
||||
return(thread);
|
||||
|
@ -281,7 +281,7 @@ void SDL_WaitThread(SDL_Thread *thread, int *status)
|
|||
*status = thread->status;
|
||||
}
|
||||
SDL_DelThread(thread);
|
||||
free(thread);
|
||||
SDL_free(thread);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
|
|||
{
|
||||
SDL_sem *sem;
|
||||
|
||||
sem = (SDL_sem *)malloc(sizeof(*sem));
|
||||
sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
|
||||
|
||||
if ( ! sem ) {
|
||||
SDL_OutOfMemory();
|
||||
|
@ -53,7 +53,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
|
|||
|
||||
D(bug("Creating semaphore %lx...\n",sem));
|
||||
|
||||
memset(sem,0,sizeof(*sem));
|
||||
SDL_memset(sem,0,sizeof(*sem));
|
||||
|
||||
InitSemaphore(&sem->Sem);
|
||||
|
||||
|
@ -66,7 +66,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
|
|||
|
||||
if ( sem ) {
|
||||
// Condizioni per liberare i task in attesa?
|
||||
free(sem);
|
||||
SDL_free(sem);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,16 +84,16 @@ static void SDL_AddThread(SDL_Thread *thread)
|
|||
SDL_numthreads, SDL_maxthreads);
|
||||
#endif
|
||||
if ( SDL_numthreads == SDL_maxthreads ) {
|
||||
threads=(SDL_Thread **)malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)*
|
||||
threads=(SDL_Thread **)SDL_malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)*
|
||||
(sizeof *threads));
|
||||
if ( threads == NULL ) {
|
||||
SDL_OutOfMemory();
|
||||
goto done;
|
||||
}
|
||||
memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads));
|
||||
SDL_memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads));
|
||||
SDL_maxthreads += ARRAY_CHUNKSIZE;
|
||||
if ( SDL_Threads ) {
|
||||
free(SDL_Threads);
|
||||
SDL_free(SDL_Threads);
|
||||
}
|
||||
SDL_Threads = threads;
|
||||
}
|
||||
|
@ -198,19 +198,19 @@ SDL_Thread *SDL_CreateThread(int (*fn)(void *), void *data)
|
|||
int ret;
|
||||
|
||||
/* Allocate memory for the thread info structure */
|
||||
thread = (SDL_Thread *)malloc(sizeof(*thread));
|
||||
thread = (SDL_Thread *)SDL_malloc(sizeof(*thread));
|
||||
if ( thread == NULL ) {
|
||||
SDL_OutOfMemory();
|
||||
return(NULL);
|
||||
}
|
||||
memset(thread, 0, (sizeof *thread));
|
||||
SDL_memset(thread, 0, (sizeof *thread));
|
||||
thread->status = -1;
|
||||
|
||||
/* Set up the arguments for the thread */
|
||||
args = (thread_args *)malloc(sizeof(*args));
|
||||
args = (thread_args *)SDL_malloc(sizeof(*args));
|
||||
if ( args == NULL ) {
|
||||
SDL_OutOfMemory();
|
||||
free(thread);
|
||||
SDL_free(thread);
|
||||
return(NULL);
|
||||
}
|
||||
args->func = fn;
|
||||
|
@ -218,8 +218,8 @@ SDL_Thread *SDL_CreateThread(int (*fn)(void *), void *data)
|
|||
args->info = thread;
|
||||
args->wait = FindTask(NULL);
|
||||
if ( args->wait == NULL ) {
|
||||
free(thread);
|
||||
free(args);
|
||||
SDL_free(thread);
|
||||
SDL_free(args);
|
||||
SDL_OutOfMemory();
|
||||
return(NULL);
|
||||
}
|
||||
|
@ -239,10 +239,10 @@ SDL_Thread *SDL_CreateThread(int (*fn)(void *), void *data)
|
|||
} else {
|
||||
/* Oops, failed. Gotta free everything */
|
||||
SDL_DelThread(thread);
|
||||
free(thread);
|
||||
SDL_free(thread);
|
||||
thread = NULL;
|
||||
}
|
||||
free(args);
|
||||
SDL_free(args);
|
||||
|
||||
/* Everything is running now */
|
||||
return(thread);
|
||||
|
@ -256,7 +256,7 @@ void SDL_WaitThread(SDL_Thread *thread, int *status)
|
|||
*status = thread->status;
|
||||
}
|
||||
SDL_DelThread(thread);
|
||||
free(thread);
|
||||
SDL_free(thread);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,12 +37,12 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
|
|||
{
|
||||
SDL_sem *sem;
|
||||
|
||||
sem = (SDL_sem *)malloc(sizeof(*sem));
|
||||
sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
|
||||
if ( sem ) {
|
||||
sem->id = create_sem(initial_value, "SDL semaphore");
|
||||
if ( sem->id < B_NO_ERROR ) {
|
||||
SDL_SetError("create_sem() failed");
|
||||
free(sem);
|
||||
SDL_free(sem);
|
||||
sem = NULL;
|
||||
}
|
||||
} else {
|
||||
|
@ -58,7 +58,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
|
|||
if ( sem->id >= B_NO_ERROR ) {
|
||||
delete_sem(sem->id);
|
||||
}
|
||||
free(sem);
|
||||
SDL_free(sem);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -113,11 +113,11 @@ struct SDL_semaphore {
|
|||
/* Create a semaphore, initialized with value */
|
||||
SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
|
||||
{
|
||||
SDL_sem *sem = (SDL_sem *) malloc(sizeof(SDL_sem));
|
||||
SDL_sem *sem = (SDL_sem *) SDL_malloc(sizeof(SDL_sem));
|
||||
if ( sem ) {
|
||||
if ( sem_init(&sem->sem_data, 0, initial_value) < 0 ) {
|
||||
SDL_SetError("sem_init() failed");
|
||||
free(sem);
|
||||
SDL_free(sem);
|
||||
sem = NULL;
|
||||
} else {
|
||||
sem->sem = &sem->sem_data;
|
||||
|
@ -132,7 +132,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
|
|||
{
|
||||
if ( sem ) {
|
||||
sem_destroy(sem->sem);
|
||||
free(sem);
|
||||
SDL_free(sem);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -322,7 +322,7 @@ sem_init(sem_t *sem, int pshared, unsigned int value)
|
|||
goto RETURN;
|
||||
}
|
||||
|
||||
*sem = (sem_t)malloc(sizeof(struct sem));
|
||||
*sem = (sem_t)SDL_malloc(sizeof(struct sem));
|
||||
if (*sem == NULL) {
|
||||
errno = ENOSPC;
|
||||
retval = -1;
|
||||
|
@ -333,7 +333,7 @@ sem_init(sem_t *sem, int pshared, unsigned int value)
|
|||
* Initialize the semaphore.
|
||||
*/
|
||||
if (pthread_mutex_init(&(*sem)->lock, NULL) != 0) {
|
||||
free(*sem);
|
||||
SDL_free(*sem);
|
||||
errno = ENOSPC;
|
||||
retval = -1;
|
||||
goto RETURN;
|
||||
|
@ -341,7 +341,7 @@ sem_init(sem_t *sem, int pshared, unsigned int value)
|
|||
|
||||
if (pthread_cond_init(&(*sem)->gtzero, NULL) != 0) {
|
||||
pthread_mutex_destroy(&(*sem)->lock);
|
||||
free(*sem);
|
||||
SDL_free(*sem);
|
||||
errno = ENOSPC;
|
||||
retval = -1;
|
||||
goto RETURN;
|
||||
|
@ -377,7 +377,7 @@ sem_destroy(sem_t *sem)
|
|||
pthread_cond_destroy(&(*sem)->gtzero);
|
||||
(*sem)->magic = 0;
|
||||
|
||||
free(*sem);
|
||||
SDL_free(*sem);
|
||||
|
||||
retval = 0;
|
||||
RETURN:
|
||||
|
|
|
@ -46,7 +46,7 @@ SDL_cond * SDL_CreateCond(void)
|
|||
{
|
||||
SDL_cond *cond;
|
||||
|
||||
cond = (SDL_cond *) malloc(sizeof(SDL_cond));
|
||||
cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
|
||||
if ( cond ) {
|
||||
cond->lock = SDL_CreateMutex();
|
||||
cond->wait_sem = SDL_CreateSemaphore(0);
|
||||
|
@ -75,7 +75,7 @@ void SDL_DestroyCond(SDL_cond *cond)
|
|||
if ( cond->lock ) {
|
||||
SDL_DestroyMutex(cond->lock);
|
||||
}
|
||||
free(cond);
|
||||
SDL_free(cond);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ SDL_mutex *SDL_CreateMutex(void)
|
|||
SDL_mutex *mutex;
|
||||
|
||||
/* Allocate mutex memory */
|
||||
mutex = (SDL_mutex *)malloc(sizeof(*mutex));
|
||||
mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
|
||||
if ( mutex ) {
|
||||
spinlock_init(&mutex->mutex);
|
||||
mutex->recursive = 0;
|
||||
|
@ -58,7 +58,7 @@ SDL_mutex *SDL_CreateMutex(void)
|
|||
void SDL_DestroyMutex(SDL_mutex *mutex)
|
||||
{
|
||||
if ( mutex ) {
|
||||
free(mutex);
|
||||
SDL_free(mutex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ SDL_cond * SDL_CreateCond(void)
|
|||
{
|
||||
SDL_cond *cond;
|
||||
|
||||
cond = (SDL_cond *) malloc(sizeof(SDL_cond));
|
||||
cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
|
||||
if ( cond ) {
|
||||
cond->lock = SDL_CreateMutex();
|
||||
cond->wait_sem = SDL_CreateSemaphore(0);
|
||||
|
@ -73,7 +73,7 @@ void SDL_DestroyCond(SDL_cond *cond)
|
|||
if ( cond->lock ) {
|
||||
SDL_DestroyMutex(cond->lock);
|
||||
}
|
||||
free(cond);
|
||||
SDL_free(cond);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,14 +40,14 @@ SDL_mutex *SDL_CreateMutex(void)
|
|||
SDL_mutex *mutex;
|
||||
|
||||
/* Allocate mutex memory */
|
||||
mutex = (SDL_mutex *)malloc(sizeof(*mutex));
|
||||
mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
|
||||
if ( mutex ) {
|
||||
/* Create the mutex semaphore, with initial value 1 */
|
||||
mutex->sem = SDL_CreateSemaphore(1);
|
||||
mutex->recursive = 0;
|
||||
mutex->owner = 0;
|
||||
if ( ! mutex->sem ) {
|
||||
free(mutex);
|
||||
SDL_free(mutex);
|
||||
mutex = NULL;
|
||||
}
|
||||
} else {
|
||||
|
@ -63,7 +63,7 @@ void SDL_DestroyMutex(SDL_mutex *mutex)
|
|||
if ( mutex->sem ) {
|
||||
SDL_DestroySemaphore(mutex->sem);
|
||||
}
|
||||
free(mutex);
|
||||
SDL_free(mutex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
|
|||
{
|
||||
SDL_sem *sem;
|
||||
|
||||
sem = (SDL_sem *)malloc(sizeof(*sem));
|
||||
sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
|
||||
if ( ! sem ) {
|
||||
SDL_OutOfMemory();
|
||||
return(0);
|
||||
|
@ -118,7 +118,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
|
|||
SDL_mutexP(sem->count_lock);
|
||||
SDL_mutexV(sem->count_lock);
|
||||
SDL_DestroyMutex(sem->count_lock);
|
||||
free(sem);
|
||||
SDL_free(sem);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,11 +62,11 @@ SDL_cond * SDL_CreateCond(void)
|
|||
{
|
||||
SDL_cond *cond;
|
||||
|
||||
cond = (SDL_cond *) malloc(sizeof(SDL_cond));
|
||||
cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
|
||||
if ( cond ) {
|
||||
if ( pthread_cond_init(&cond->cond, NULL) < 0 ) {
|
||||
SDL_SetError("pthread_cond_init() failed");
|
||||
free(cond);
|
||||
SDL_free(cond);
|
||||
cond = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ void SDL_DestroyCond(SDL_cond *cond)
|
|||
{
|
||||
if ( cond ) {
|
||||
pthread_cond_destroy(&cond->cond);
|
||||
free(cond);
|
||||
SDL_free(cond);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ SDL_mutex *SDL_CreateMutex (void)
|
|||
#endif /* PTHREAD_RECURSIVE_MUTEX */
|
||||
if ( pthread_mutex_init(&mutex->id, &attr) != 0 ) {
|
||||
SDL_SetError("pthread_mutex_init() failed");
|
||||
free(mutex);
|
||||
SDL_free(mutex);
|
||||
mutex = NULL;
|
||||
}
|
||||
} else {
|
||||
|
@ -84,7 +84,7 @@ void SDL_DestroyMutex(SDL_mutex *mutex)
|
|||
{
|
||||
if ( mutex ) {
|
||||
pthread_mutex_destroy(&mutex->id);
|
||||
free(mutex);
|
||||
SDL_free(mutex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ struct SDL_semaphore {
|
|||
/* Create a semaphore, initialized with value */
|
||||
SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
|
||||
{
|
||||
SDL_sem *sem = (SDL_sem *) malloc(sizeof(SDL_sem));
|
||||
SDL_sem *sem = (SDL_sem *) SDL_malloc(sizeof(SDL_sem));
|
||||
if ( sem ) {
|
||||
#ifdef USE_NAMED_SEMAPHORES
|
||||
static int semnum = 0;
|
||||
|
@ -78,7 +78,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
|
|||
sem->sem = sem_open(name, O_CREAT, 0600, initial_value);
|
||||
if ( sem->sem == (sem_t *)SEM_FAILED ) {
|
||||
SDL_SetError("sem_open(%s) failed", name);
|
||||
free(sem);
|
||||
SDL_free(sem);
|
||||
sem = NULL;
|
||||
} else {
|
||||
sem_unlink(name);
|
||||
|
@ -86,7 +86,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
|
|||
#else
|
||||
if ( sem_init(&sem->sem_data, 0, initial_value) < 0 ) {
|
||||
SDL_SetError("sem_init() failed");
|
||||
free(sem);
|
||||
SDL_free(sem);
|
||||
sem = NULL;
|
||||
} else {
|
||||
sem->sem = &sem->sem_data;
|
||||
|
@ -106,7 +106,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
|
|||
#else
|
||||
sem_destroy(sem->sem);
|
||||
#endif
|
||||
free(sem);
|
||||
SDL_free(sem);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
|
|||
union semun init;
|
||||
key_t key;
|
||||
|
||||
sem = (SDL_sem *)malloc(sizeof(*sem));
|
||||
sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
|
||||
if ( sem == NULL ) {
|
||||
SDL_OutOfMemory();
|
||||
return(NULL);
|
||||
|
@ -269,7 +269,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
|
|||
/* Report the error if we eventually failed */
|
||||
if ( sem->id < 0 ) {
|
||||
SDL_SetError("Couldn't create semaphore");
|
||||
free(sem);
|
||||
SDL_free(sem);
|
||||
return(NULL);
|
||||
}
|
||||
init.val = initial_value; /* Initialize semaphore */
|
||||
|
@ -287,7 +287,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
|
|||
dummy.val = 0;
|
||||
semctl(sem->id, 0, IPC_RMID, dummy);
|
||||
#endif
|
||||
free(sem);
|
||||
SDL_free(sem);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
|
|||
void *stack;
|
||||
|
||||
/* Allocate memory for thread stack */
|
||||
stack = malloc(STACKSIZE);
|
||||
stack = SDL_malloc(STACKSIZE);
|
||||
if ( stack == (void *)0 ) {
|
||||
SDL_OutOfMemory();
|
||||
return(-1);
|
||||
|
@ -186,7 +186,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
|
|||
thread->handle = clone(RunThread, stack,
|
||||
(CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND), args);
|
||||
if ( thread->handle < 0 ) {
|
||||
free(thread->data);
|
||||
SDL_free(thread->data);
|
||||
SDL_SetError("Not enough resources to create thread");
|
||||
return(-1);
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ void SDL_SYS_WaitThread(SDL_Thread *thread)
|
|||
while ( system(command) == 0 )
|
||||
sleep(1);
|
||||
#endif
|
||||
free(thread->data);
|
||||
SDL_free(thread->data);
|
||||
}
|
||||
|
||||
void SDL_SYS_KillThread(SDL_Thread *thread)
|
||||
|
|
|
@ -46,7 +46,7 @@ DECLSPEC SDL_cond * SDLCALL SDL_CreateCond(void)
|
|||
{
|
||||
SDL_cond *cond;
|
||||
|
||||
cond = (SDL_cond *) malloc(sizeof(SDL_cond));
|
||||
cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
|
||||
if ( cond ) {
|
||||
cond->lock = SDL_CreateMutex();
|
||||
cond->wait_sem = SDL_CreateSemaphore(0);
|
||||
|
@ -75,7 +75,7 @@ DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond)
|
|||
if ( cond->lock ) {
|
||||
SDL_DestroyMutex(cond->lock);
|
||||
}
|
||||
free(cond);
|
||||
SDL_free(cond);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ DECLSPEC SDL_mutex * SDLCALL SDL_CreateMutex(void)
|
|||
APIRET ulrc;
|
||||
|
||||
/* Allocate mutex memory */
|
||||
mutex = (SDL_mutex *)malloc(sizeof(*mutex));
|
||||
mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
|
||||
if (mutex)
|
||||
{
|
||||
/* Create the mutex, with initial value signaled */
|
||||
|
@ -54,7 +54,7 @@ DECLSPEC SDL_mutex * SDLCALL SDL_CreateMutex(void)
|
|||
if (ulrc!=NO_ERROR)
|
||||
{
|
||||
SDL_SetError("Couldn't create mutex");
|
||||
free(mutex);
|
||||
SDL_free(mutex);
|
||||
mutex = NULL;
|
||||
}
|
||||
} else {
|
||||
|
@ -73,7 +73,7 @@ DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex *mutex)
|
|||
DosCloseMutexSem(mutex->hmtxID);
|
||||
mutex->hmtxID = 0;
|
||||
}
|
||||
free(mutex);
|
||||
SDL_free(mutex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,13 +48,13 @@ DECLSPEC SDL_sem * SDLCALL SDL_CreateSemaphore(Uint32 initial_value)
|
|||
ULONG ulrc;
|
||||
|
||||
/* Allocate sem memory */
|
||||
sem = (SDL_sem *)malloc(sizeof(*sem));
|
||||
sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
|
||||
if ( sem ) {
|
||||
/* Create the mutex semaphore */
|
||||
ulrc = DosCreateMutexSem(NULL,&(sem->id),0,TRUE);
|
||||
if ( ulrc ) {
|
||||
SDL_SetError("Couldn't create semaphore");
|
||||
free(sem);
|
||||
SDL_free(sem);
|
||||
sem = NULL;
|
||||
} else
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem)
|
|||
DosCloseMutexSem(sem->id);
|
||||
sem->id = 0;
|
||||
}
|
||||
free(sem);
|
||||
SDL_free(sem);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ static void threadfunc(void *pparm)
|
|||
if (pThreadParms)
|
||||
{
|
||||
pfnCurrentEndThread = pThreadParms->pfnCurrentEndThread;
|
||||
free(pThreadParms);
|
||||
SDL_free(pThreadParms);
|
||||
}
|
||||
// Call endthread!
|
||||
if (pfnCurrentEndThread)
|
||||
|
@ -60,7 +60,7 @@ static void threadfunc(void *pparm)
|
|||
|
||||
int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread)
|
||||
{
|
||||
pThreadStartParms pThreadParms = malloc(sizeof(tThreadStartParms));
|
||||
pThreadStartParms pThreadParms = SDL_malloc(sizeof(tThreadStartParms));
|
||||
if (!pThreadParms)
|
||||
{
|
||||
SDL_SetError("Not enough memory to create thread");
|
||||
|
|
|
@ -18,11 +18,11 @@ SDL_cond * SDL_CreateCond(void)
|
|||
{
|
||||
SDL_cond *cond;
|
||||
|
||||
cond = (SDL_cond *) malloc(sizeof(SDL_cond));
|
||||
cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
|
||||
if ( cond ) {
|
||||
if ( pth_cond_init(&(cond->condpth_p)) < 0 ) {
|
||||
SDL_SetError("pthread_cond_init() failed");
|
||||
free(cond);
|
||||
SDL_free(cond);
|
||||
cond = NULL;
|
||||
}
|
||||
} else {
|
||||
|
@ -35,7 +35,7 @@ SDL_cond * SDL_CreateCond(void)
|
|||
void SDL_DestroyCond(SDL_cond *cond)
|
||||
{
|
||||
if ( cond ) {
|
||||
free(cond);
|
||||
SDL_free(cond);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,12 +18,12 @@ SDL_mutex *SDL_CreateMutex(void)
|
|||
SDL_mutex *mutex;
|
||||
|
||||
/* Allocate mutex memory */
|
||||
mutex = (SDL_mutex *)malloc(sizeof(*mutex));
|
||||
mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
|
||||
if ( mutex ) {
|
||||
/* Create the mutex, with initial value signaled */
|
||||
if (!pth_mutex_init(&(mutex->mutexpth_p))) {
|
||||
SDL_SetError("Couldn't create mutex");
|
||||
free(mutex);
|
||||
SDL_free(mutex);
|
||||
mutex = NULL;
|
||||
}
|
||||
} else {
|
||||
|
@ -36,7 +36,7 @@ SDL_mutex *SDL_CreateMutex(void)
|
|||
void SDL_DestroyMutex(SDL_mutex *mutex)
|
||||
{
|
||||
if ( mutex ) {
|
||||
free(mutex);
|
||||
SDL_free(mutex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,11 +45,11 @@ SDL_cond * SDL_CreateCond(void)
|
|||
{
|
||||
SDL_cond *cond;
|
||||
|
||||
cond = (SDL_cond *) malloc(sizeof(SDL_cond));
|
||||
cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
|
||||
if ( cond ) {
|
||||
if ( pthread_cond_init(&cond->cond, NULL) < 0 ) {
|
||||
SDL_SetError("pthread_cond_init() failed");
|
||||
free(cond);
|
||||
SDL_free(cond);
|
||||
cond = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ void SDL_DestroyCond(SDL_cond *cond)
|
|||
{
|
||||
if ( cond ) {
|
||||
pthread_cond_destroy(&cond->cond);
|
||||
free(cond);
|
||||
SDL_free(cond);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ SDL_mutex *SDL_CreateMutex (void)
|
|||
#endif /* PTHREAD_NO_RECURSIVE_MUTEX */
|
||||
if ( pthread_mutex_init(&mutex->id, &attr) != 0 ) {
|
||||
SDL_SetError("pthread_mutex_init() failed");
|
||||
free(mutex);
|
||||
SDL_free(mutex);
|
||||
mutex = NULL;
|
||||
}
|
||||
} else {
|
||||
|
@ -70,7 +70,7 @@ void SDL_DestroyMutex(SDL_mutex *mutex)
|
|||
{
|
||||
if ( mutex ) {
|
||||
pthread_mutex_destroy(&mutex->id);
|
||||
free(mutex);
|
||||
SDL_free(mutex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,11 +90,11 @@ struct SDL_semaphore {
|
|||
/* Create a semaphore, initialized with value */
|
||||
SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
|
||||
{
|
||||
SDL_sem *sem = (SDL_sem *) malloc(sizeof(SDL_sem));
|
||||
SDL_sem *sem = (SDL_sem *) SDL_malloc(sizeof(SDL_sem));
|
||||
if ( sem ) {
|
||||
if ( sem_init(&sem->sem_data, 0, initial_value) < 0 ) {
|
||||
SDL_SetError("sem_init() failed");
|
||||
free(sem);
|
||||
SDL_free(sem);
|
||||
sem = NULL;
|
||||
} else {
|
||||
sem->sem = &sem->sem_data;
|
||||
|
@ -109,7 +109,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
|
|||
{
|
||||
if ( sem ) {
|
||||
sem_destroy(sem->sem);
|
||||
free(sem);
|
||||
SDL_free(sem);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,13 +39,13 @@ SDL_mutex *SDL_CreateMutex(void)
|
|||
SDL_mutex *mutex;
|
||||
|
||||
/* Allocate mutex memory */
|
||||
mutex = (SDL_mutex *)malloc(sizeof(*mutex));
|
||||
mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
|
||||
if ( mutex ) {
|
||||
/* Create the mutex, with initial value signaled */
|
||||
mutex->id = CreateMutex(NULL, FALSE, NULL);
|
||||
if ( ! mutex->id ) {
|
||||
SDL_SetError("Couldn't create mutex");
|
||||
free(mutex);
|
||||
SDL_free(mutex);
|
||||
mutex = NULL;
|
||||
}
|
||||
} else {
|
||||
|
@ -62,7 +62,7 @@ void SDL_DestroyMutex(SDL_mutex *mutex)
|
|||
CloseHandle(mutex->id);
|
||||
mutex->id = 0;
|
||||
}
|
||||
free(mutex);
|
||||
SDL_free(mutex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
|
|||
SDL_sem *sem;
|
||||
|
||||
/* Allocate sem memory */
|
||||
sem = (SDL_sem *)malloc(sizeof(*sem));
|
||||
sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
|
||||
if ( sem ) {
|
||||
/* Create the semaphore, with max value 32K */
|
||||
#if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
|
||||
|
@ -59,7 +59,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
|
|||
sem->count = initial_value;
|
||||
if ( ! sem->id ) {
|
||||
SDL_SetError("Couldn't create semaphore");
|
||||
free(sem);
|
||||
SDL_free(sem);
|
||||
sem = NULL;
|
||||
}
|
||||
} else {
|
||||
|
@ -80,7 +80,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
|
|||
#endif
|
||||
sem->id = 0;
|
||||
}
|
||||
free(sem);
|
||||
SDL_free(sem);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ static unsigned __stdcall RunThread(void *data)
|
|||
if (pThreadParms)
|
||||
{
|
||||
pfnCurrentEndThread = pThreadParms->pfnCurrentEndThread;
|
||||
free(pThreadParms);
|
||||
SDL_free(pThreadParms);
|
||||
}
|
||||
// Call endthread!
|
||||
if (pfnCurrentEndThread)
|
||||
|
@ -58,7 +58,7 @@ static unsigned __stdcall RunThread(void *data)
|
|||
int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread)
|
||||
{
|
||||
unsigned threadid;
|
||||
pThreadStartParms pThreadParms = (pThreadStartParms)malloc(sizeof(tThreadStartParms));
|
||||
pThreadStartParms pThreadParms = (pThreadStartParms)SDL_malloc(sizeof(tThreadStartParms));
|
||||
if (!pThreadParms) {
|
||||
SDL_OutOfMemory();
|
||||
return(-1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue