Wiki Page Content

SDL_DestroyMutex

Use this function to destroy a mutex created with SDL_CreateMutex().

Syntax

void SDL_DestroyMutex(SDL_mutex* mutex)

Function Parameters

mutex

the mutex to destroy

Code Examples

SDL_mutex *mutex;

mutex = SDL_CreateMutex();
if (!mutex) {
  fprintf(stderr, "Couldn't create mutex\n");
  return;
}

if (SDL_LockMutex(mutex) == 0) {
  /* Do stuff while mutex is locked */
  SDL_UnlockMutex(mutex);
} else {
  fprintf(stderr, "Couldn't lock mutex\n");
}

SDL_DestroyMutex(mutex);

Remarks

This function must be called on any mutex that is no longer needed. Failure to destroy a mutex will result in a system memory or resource leak. While it is safe to destroy a mutex that is UNLOCKED, it is not safe to attempt to destroy a locked mutex and may result in undefined behavior depending on the platform.


CategoryAPI, CategoryMutex

None: SDL_DestroyMutex (last edited 2013-10-04 13:35:45 by urkle)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit