src/thread/beos/SDL_syssem.c
changeset 1336 3692456e7b0f
parent 1312 c9b51268668f
child 1358 c71e05b4dc2e
equal deleted inserted replaced
1335:c39265384763 1336:3692456e7b0f
    35 /* Create a counting semaphore */
    35 /* Create a counting semaphore */
    36 SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
    36 SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
    37 {
    37 {
    38 	SDL_sem *sem;
    38 	SDL_sem *sem;
    39 
    39 
    40 	sem = (SDL_sem *)malloc(sizeof(*sem));
    40 	sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
    41 	if ( sem ) {
    41 	if ( sem ) {
    42 		sem->id = create_sem(initial_value, "SDL semaphore");
    42 		sem->id = create_sem(initial_value, "SDL semaphore");
    43 		if ( sem->id < B_NO_ERROR ) {
    43 		if ( sem->id < B_NO_ERROR ) {
    44 			SDL_SetError("create_sem() failed");
    44 			SDL_SetError("create_sem() failed");
    45 			free(sem);
    45 			SDL_free(sem);
    46 			sem = NULL;
    46 			sem = NULL;
    47 		}
    47 		}
    48 	} else {
    48 	} else {
    49 		SDL_OutOfMemory();
    49 		SDL_OutOfMemory();
    50 	}
    50 	}
    56 {
    56 {
    57 	if ( sem ) {
    57 	if ( sem ) {
    58 		if ( sem->id >= B_NO_ERROR ) {
    58 		if ( sem->id >= B_NO_ERROR ) {
    59 			delete_sem(sem->id);
    59 			delete_sem(sem->id);
    60 		}
    60 		}
    61 		free(sem);
    61 		SDL_free(sem);
    62 	}
    62 	}
    63 }
    63 }
    64 
    64 
    65 int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
    65 int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
    66 {
    66 {