comparison src/thread/amigaos/SDL_thread.c @ 1336:3692456e7b0f

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...
author Sam Lantinga <slouken@libsdl.org>
date Tue, 07 Feb 2006 06:59:48 +0000
parents c9b51268668f
children 604d73db6802
comparison
equal deleted inserted replaced
1335:c39265384763 1336:3692456e7b0f
82 #ifdef DEBUG_THREADS 82 #ifdef DEBUG_THREADS
83 printf("Adding thread (%d already - %d max)\n", 83 printf("Adding thread (%d already - %d max)\n",
84 SDL_numthreads, SDL_maxthreads); 84 SDL_numthreads, SDL_maxthreads);
85 #endif 85 #endif
86 if ( SDL_numthreads == SDL_maxthreads ) { 86 if ( SDL_numthreads == SDL_maxthreads ) {
87 threads=(SDL_Thread **)malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)* 87 threads=(SDL_Thread **)SDL_malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)*
88 (sizeof *threads)); 88 (sizeof *threads));
89 if ( threads == NULL ) { 89 if ( threads == NULL ) {
90 SDL_OutOfMemory(); 90 SDL_OutOfMemory();
91 goto done; 91 goto done;
92 } 92 }
93 memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads)); 93 SDL_memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads));
94 SDL_maxthreads += ARRAY_CHUNKSIZE; 94 SDL_maxthreads += ARRAY_CHUNKSIZE;
95 if ( SDL_Threads ) { 95 if ( SDL_Threads ) {
96 free(SDL_Threads); 96 SDL_free(SDL_Threads);
97 } 97 }
98 SDL_Threads = threads; 98 SDL_Threads = threads;
99 } 99 }
100 SDL_Threads[SDL_numthreads++] = thread; 100 SDL_Threads[SDL_numthreads++] = thread;
101 done: 101 done:
196 SDL_Thread *thread; 196 SDL_Thread *thread;
197 thread_args *args; 197 thread_args *args;
198 int ret; 198 int ret;
199 199
200 /* Allocate memory for the thread info structure */ 200 /* Allocate memory for the thread info structure */
201 thread = (SDL_Thread *)malloc(sizeof(*thread)); 201 thread = (SDL_Thread *)SDL_malloc(sizeof(*thread));
202 if ( thread == NULL ) { 202 if ( thread == NULL ) {
203 SDL_OutOfMemory(); 203 SDL_OutOfMemory();
204 return(NULL); 204 return(NULL);
205 } 205 }
206 memset(thread, 0, (sizeof *thread)); 206 SDL_memset(thread, 0, (sizeof *thread));
207 thread->status = -1; 207 thread->status = -1;
208 208
209 /* Set up the arguments for the thread */ 209 /* Set up the arguments for the thread */
210 args = (thread_args *)malloc(sizeof(*args)); 210 args = (thread_args *)SDL_malloc(sizeof(*args));
211 if ( args == NULL ) { 211 if ( args == NULL ) {
212 SDL_OutOfMemory(); 212 SDL_OutOfMemory();
213 free(thread); 213 SDL_free(thread);
214 return(NULL); 214 return(NULL);
215 } 215 }
216 args->func = fn; 216 args->func = fn;
217 args->data = data; 217 args->data = data;
218 args->info = thread; 218 args->info = thread;
219 args->wait = FindTask(NULL); 219 args->wait = FindTask(NULL);
220 if ( args->wait == NULL ) { 220 if ( args->wait == NULL ) {
221 free(thread); 221 SDL_free(thread);
222 free(args); 222 SDL_free(args);
223 SDL_OutOfMemory(); 223 SDL_OutOfMemory();
224 return(NULL); 224 return(NULL);
225 } 225 }
226 226
227 /* Add the thread to the list of available threads */ 227 /* Add the thread to the list of available threads */
237 Wait(SIGBREAKF_CTRL_E); 237 Wait(SIGBREAKF_CTRL_E);
238 D(bug(" Arrived.")); 238 D(bug(" Arrived."));
239 } else { 239 } else {
240 /* Oops, failed. Gotta free everything */ 240 /* Oops, failed. Gotta free everything */
241 SDL_DelThread(thread); 241 SDL_DelThread(thread);
242 free(thread); 242 SDL_free(thread);
243 thread = NULL; 243 thread = NULL;
244 } 244 }
245 free(args); 245 SDL_free(args);
246 246
247 /* Everything is running now */ 247 /* Everything is running now */
248 return(thread); 248 return(thread);
249 } 249 }
250 250
254 SDL_SYS_WaitThread(thread); 254 SDL_SYS_WaitThread(thread);
255 if ( status ) { 255 if ( status ) {
256 *status = thread->status; 256 *status = thread->status;
257 } 257 }
258 SDL_DelThread(thread); 258 SDL_DelThread(thread);
259 free(thread); 259 SDL_free(thread);
260 } 260 }
261 } 261 }
262 262
263 Uint32 SDL_GetThreadID(SDL_Thread *thread) 263 Uint32 SDL_GetThreadID(SDL_Thread *thread)
264 { 264 {