Wiki Page Content

Revision 6 as of 2011-03-18 21:27:22

Clear message

DRAFT

SDL_DestroyMutex

Use this function to destroy a mutex.

Syntax

void SDL_DestroyMutex(SDL_mutex* mutex)

Function Parameters

mutex

the mutex to destroy

Code Examples

SDL_mutex *mutex;

//First create the mutex..
mutex = SDL_CreateMutex();

// ... use mutex in code


// When done using the mutex, destroy it

// MAKE sure to unlock the mutex prior to destroying it
if( SDL_mutexV( mutex ) )
  printf("\nSDL Mutex unlock error:%s", SDL_GetError());
else
  // When done with the mutex delete it
  SDL_DestroyMutex( mutex );

Remarks

SDL_DestroyMutex 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.

Any attempt to reference a mutex after it has been destroyed will cause access to an invalid memory pointer which may lead to memory corruption or a segmentation fault.


CategoryAPI, CategoryMutex

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