src/thread/win32/SDL_sysmutex.c
changeset 1336 3692456e7b0f
parent 1330 450721ad5436
child 1338 604d73db6802
equal deleted inserted replaced
1335:c39265384763 1336:3692456e7b0f
    37 SDL_mutex *SDL_CreateMutex(void)
    37 SDL_mutex *SDL_CreateMutex(void)
    38 {
    38 {
    39 	SDL_mutex *mutex;
    39 	SDL_mutex *mutex;
    40 
    40 
    41 	/* Allocate mutex memory */
    41 	/* Allocate mutex memory */
    42 	mutex = (SDL_mutex *)malloc(sizeof(*mutex));
    42 	mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
    43 	if ( mutex ) {
    43 	if ( mutex ) {
    44 		/* Create the mutex, with initial value signaled */
    44 		/* Create the mutex, with initial value signaled */
    45 		mutex->id = CreateMutex(NULL, FALSE, NULL);
    45 		mutex->id = CreateMutex(NULL, FALSE, NULL);
    46 		if ( ! mutex->id ) {
    46 		if ( ! mutex->id ) {
    47 			SDL_SetError("Couldn't create mutex");
    47 			SDL_SetError("Couldn't create mutex");
    48 			free(mutex);
    48 			SDL_free(mutex);
    49 			mutex = NULL;
    49 			mutex = NULL;
    50 		}
    50 		}
    51 	} else {
    51 	} else {
    52 		SDL_OutOfMemory();
    52 		SDL_OutOfMemory();
    53 	}
    53 	}
    60 	if ( mutex ) {
    60 	if ( mutex ) {
    61 		if ( mutex->id ) {
    61 		if ( mutex->id ) {
    62 			CloseHandle(mutex->id);
    62 			CloseHandle(mutex->id);
    63 			mutex->id = 0;
    63 			mutex->id = 0;
    64 		}
    64 		}
    65 		free(mutex);
    65 		SDL_free(mutex);
    66 	}
    66 	}
    67 }
    67 }
    68 
    68 
    69 /* Lock the mutex */
    69 /* Lock the mutex */
    70 int SDL_mutexP(SDL_mutex *mutex)
    70 int SDL_mutexP(SDL_mutex *mutex)