src/thread/generic/SDL_syssem.c
changeset 1627 aee7ea396f59
parent 1402 d910939febfa
child 1662 782fd950bd46
child 1895 c121d94672cb
child 4159 a1b03ba2fcd0
     1.1 --- a/src/thread/generic/SDL_syssem.c	Thu Apr 13 13:38:40 2006 +0000
     1.2 +++ b/src/thread/generic/SDL_syssem.c	Thu Apr 13 14:04:13 2006 +0000
     1.3 @@ -87,7 +87,7 @@
     1.4  	sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
     1.5  	if ( ! sem ) {
     1.6  		SDL_OutOfMemory();
     1.7 -		return(0);
     1.8 +		return NULL;
     1.9  	}
    1.10  	sem->count = initial_value;
    1.11  	sem->waiters_count = 0;
    1.12 @@ -96,10 +96,10 @@
    1.13  	sem->count_nonzero = SDL_CreateCond();
    1.14  	if ( ! sem->count_lock || ! sem->count_nonzero ) {
    1.15  		SDL_DestroySemaphore(sem);
    1.16 -		return(0);
    1.17 +		return NULL;
    1.18  	}
    1.19  
    1.20 -	return(sem);
    1.21 +	return sem;
    1.22  }
    1.23  
    1.24  /* WARNING:
    1.25 @@ -114,9 +114,11 @@
    1.26  			SDL_Delay(10);
    1.27  		}
    1.28  		SDL_DestroyCond(sem->count_nonzero);
    1.29 -		SDL_mutexP(sem->count_lock);
    1.30 -		SDL_mutexV(sem->count_lock);
    1.31 -		SDL_DestroyMutex(sem->count_lock);
    1.32 +		if ( sem->count_lock ) {
    1.33 +			SDL_mutexP(sem->count_lock);
    1.34 +			SDL_mutexV(sem->count_lock);
    1.35 +			SDL_DestroyMutex(sem->count_lock);
    1.36 +		}
    1.37  		SDL_free(sem);
    1.38  	}
    1.39  }