Wiki Page Content

Differences between revisions 5 and 6
Revision 5 as of 2011-02-28 21:50:35
Size: 1399
Editor: Paul Walters
Comment: Added code example, udpated remarks
Revision 6 as of 2011-03-18 21:27:22
Size: 1405
Editor: SheenaSmith
Comment: camelcase pragma change, fixed links
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
#pragma disable-camelcase #pragma camelcase off
Line 15: Line 15:
Line 39: Line 40:
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. [[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 47: Line 48:
[[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