A question regarding pthread_mutexattr_init() and pthread_mutexattr_destroy().
I understand that one uses …init() to create an mutex attribute, and that …destroy() destroys the mutex attribute.
But is the destroy really necessary? I’ve seen utility code in my work base where a function is called multiple times and they invoke the init() function each time, to create a new mutex, but they don’t invoke destroy() on the attribute.
How grouchy should I get with my co-workers about this?
I am concerned because one of the return values from init() is ENOMEM which makes me think that the mutex attr is an opaque structure that dynamically allocates some memory, attaching it to the attr.
Which would then imply we have a memory leak as they init but don’t destroy.
Any advice, or comments?