Fixed a minor memory leak in the SDL thread subsystem
authorSam Lantinga <slouken@libsdl.org>
Thu, 11 Apr 2002 21:08:44 +0000
changeset 340b9f1ce709960
parent 339 eed579d059ef
child 341 6ca967a46bf1
Fixed a minor memory leak in the SDL thread subsystem
src/thread/SDL_thread.c
     1.1 --- a/src/thread/SDL_thread.c	Thu Apr 11 18:22:05 2002 +0000
     1.2 +++ b/src/thread/SDL_thread.c	Thu Apr 11 21:08:44 2002 +0000
     1.3 @@ -146,10 +146,15 @@
     1.4  			}
     1.5  		}
     1.6  		if ( i < SDL_numthreads ) {
     1.7 -			--SDL_numthreads;
     1.8 -			while ( i < SDL_numthreads ) {
     1.9 -				SDL_Threads[i] = SDL_Threads[i+1];
    1.10 -				++i;
    1.11 +			if ( --SDL_numthreads > 0 ) {
    1.12 +				while ( i < SDL_numthreads ) {
    1.13 +					SDL_Threads[i] = SDL_Threads[i+1];
    1.14 +					++i;
    1.15 +				}
    1.16 +			} else {
    1.17 +				SDL_maxthreads = 0;
    1.18 +				free(SDL_Threads);
    1.19 +				SDL_Threads = NULL;
    1.20  			}
    1.21  #ifdef DEBUG_THREADS
    1.22  			printf("Deleting thread (%d left - %d max)\n",