Page 1 of 1

[RCF::getRootMutex] Memory Leak ?

Posted: Tue Jan 14, 2014 9:26 am
by acDev
Original:

Code: Select all

    Mutex & getRootMutex()
    {
        static Mutex * gpRootMutex = new Mutex;
        return *gpRootMutex;
    }
My way:

Code: Select all

    Mutex gRootMutex;

    Mutex & getRootMutex()
    {
        return gRootMutex;
    }

Re: [RCF::getRootMutex] Memory Leak ?

Posted: Wed Jan 15, 2014 1:07 am
by jarl
The purpose of the root mutex is to provide thread safe initialization and deinitialization. As such it has to exist permanently, which is why we don't delete it.

It's not a memory leak, as there is only ever one such mutex.