'Is it dangerous/bad to call pthread_mutex_destroy with an uninitialized mutex
Example code:
#include <pthread.h>
int main(void)
{
pthread_mutex_t mutex;
pthread_mutex_destroy(&mutex);
return (0);
}
Is this a problem? I want to use a function that frees all allocated memory and destroys all mutexes in case of an error and returns, but i would sometimes call it when some of the mutexes are uninitialized. Would that be a problem?
Edit: Linux man says it's undefined behavior (https://man7.org/linux/man-pages/man3/pthread_mutex_destroy.3p.html) Guess that means i probably shouldn't do it, but if it just affects the mutex i'm trying to destroy, and nothing else, should be fine if i don't use it afterwards, right?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
