src/mutex.c
/**
 * Allocates a mutex attribute and sets its type to PTHREAD_MUTEX_ERRORCHECK.
 *
 * @return The mutex attribute or NULL if an error occurred.
 */
Allocates a mutex attribute and sets its type to PTHREAD_MUTEX_ERRORCHECK.
@return The mutex attribute or NULL if an error occurred.
Allocates a mutex attribute and sets its type to PTHREAD_MUTEX_ERRORCHECK . @return The mutex attribute or NULL if an error occurred .
pthread_mutexattr_t *createMutexAttribute() {
    pthread_mutexattr_t *attribute = (pthread_mutexattr_t*) malloc(sizeof(pthread_mutexattr_t));
    if (NULL == attribute) {
        printError(
			errno,
			__FILE__,
			__PRETTY_FUNCTION__,
			"Could not allocate memory for attribute."
		);
        return NULL;
    }
    if (0 != (errno = pthread_mutexattr_init(attribute))) {
	    printError(
		    errno,
		    __FILE__,
		    __PRETTY_FUNCTION__,
		    "Could not initialize attribute."
	    );
        free(attribute);
        return NULL;
    }
    if (0 != (errno = pthread_mutexattr_settype(attribute, PTHREAD_MUTEX_ERRORCHECK))) {
	    printError(
		    errno,
		    __FILE__,
		    __PRETTY_FUNCTION__,
		    "Could not set attribute type."
	    );
        free(attribute);
        return NULL;
    }
    return attribute;
}
pthread_mutexattr_t * createMutexAttribute ( ) { pthread_mutexattr_t * attribute = ( pthread_mutexattr_t * ) malloc ( sizeof ( pthread_mutexattr_t ) ) ; if ( NULL == attribute ) { printError ( errno , __FILE__ , __PRETTY_FUNCTION__ , " " ) ; return NULL ; } if ( 0 != ( errno = pthread_mutexattr_init ( attribute ) ) ) { printError ( errno , __FILE__ , __PRETTY_FUNCTION__ , " " ) ; free ( attribute ) ; return NULL ; } if ( 0 != ( errno = pthread_mutexattr_settype ( attribute , PTHREAD_MUTEX_ERRORCHECK ) ) ) { printError ( errno , __FILE__ , __PRETTY_FUNCTION__ , " " ) ; free ( attribute ) ; return NULL ; } return attribute ; }
Allocates a mutex attribute and sets its type to PTHREAD_MUTEX_ERRORCHECK.
Allocates a mutex attribute and sets its type to PTHREAD_MUTEX_ERRORCHECK .