Suppose I use
pthread_mutex_t *m = new pthread_mutex_t;
pthread_mutex_init(m, NULL);
to initialize a mutex. Then after I’m done, and invoke pthread_mutex_destroy, do I need to use
delete m;
to release all resources?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to free the memory, as
pthread_mutex_destroycan’t do it for you.Why doesn’t pthread_mutex_destroy free the memory for you ? Because you are allowed to do this:
You can try it using
valgrind: