Wiki Page Content

Differences between revisions 4 and 5
Revision 4 as of 2010-10-18 02:12:19
Size: 588
Editor: SheenaSmith
Comment: update content - pointers, structs
Revision 5 as of 2011-02-28 21:50:35
Size: 1399
Editor: Paul Walters
Comment: Added code example, udpated remarks
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
||<tablewidth="100%" style="color: #FF0000;" :> DRAFT|| ||<tablewidth="100%"style="color: rgb(255, 0, 0); text-align: center;">DRAFT ||
Line 14: Line 15:
== Function Parameters ==
||'''mutex''' ||^the mutex to destroy^ ||
Line 15: Line 18:
== Function Parameters ==
||'''mutex'''||^the mutex to destroy^||
Line 20: Line 21:
You can add your code example here 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 );
Line 22: Line 38:
== 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.
Line 23: Line 41:
== Remarks ==
''You can add useful comments here''
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.
Line 27: Line 44:
 .[[SDL_CreateMutex]] *  . [[SDL_CreateMutex]] *
Line 30: Line 47:
[[CategoryAPI]], [[CategoryMutex]] [[CategoryAPI]], CategoryMutex

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

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