1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
// ****************************************************************************
// Project: GUYMAGER
// ****************************************************************************
// Programmer: Guy Voncken
// Police Grand-Ducale
// Service de Police Judiciaire
// Section Nouvelles Technologies
// ****************************************************************************
// Module: Different utility functions
// ****************************************************************************
#include "common.h"
#include <QtGui>
#include "config.h"
#define MEMWATCH
#define MEMWATCH_NOCPP
#include "memwatch.h"
#undef malloc // These have been defined in memwatch.h. We must undefine them
#undef free // in order to be able to access std::malloc and std::free
#include "util.h"
static QMutex MutexMemAccess;
void *UtilMemAlloc (size_t Size, const char *pFile, int Line)
{
void *pMem;
if (CONFIG(UseMemWatch))
{
MutexMemAccess.lock();
pMem = mwMalloc (Size, pFile, Line);
MutexMemAccess.unlock();
}
else
{
pMem = malloc(Size);
}
return pMem;
}
void UtilMemFree (void *pMem, const char *pFile, int Line)
{
if (CONFIG(UseMemWatch))
{
MutexMemAccess.lock();
mwFree (pMem, pFile, Line);
MutexMemAccess.unlock();
}
else
{
free (pMem);
}
}
|