Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
MallocGuard.h File Reference
#include "Stroika/Foundation/StroikaPreComp.h"
#include <array>
#include "Stroika/Foundation/Characters/SDKChar.h"
#include "Stroika/Foundation/Characters/SDKString.h"
#include "Stroika/Foundation/Common/Common.h"
#include "Stroika/Foundation/Debug/CompileTimeFlagChecker.h"
#include "Stroika/Foundation/Time/Realtime.h"
#include "MallocGuard.inl"

Go to the source code of this file.

Namespaces

namespace  Stroika::Foundation
 

Macros

#define qStroika_Foundation_Debug_MallocGuard   0
 
#define qStroika_Foundation_Debug_MallocGuard_GuardSize   16
 

Detailed Description

Note
Code-Status: Beta

TODO:

Definition in file MallocGuard.h.

Macro Definition Documentation

◆ qStroika_Foundation_Debug_MallocGuard

#define qStroika_Foundation_Debug_MallocGuard   0

If qStroika_Foundation_Debug_MallocGuard defined to 1, wrap malloc(), free () etc, to do extra checking for corruption, double free write off the ends, etc.

This works in DEBUG or RELEASE builds.

This - so far - only works for GCC.

This may not work perfectly if you call some weird malloc variants, or mix __libc_malloc with free (), etc.

Note
You can enable this feature with ./configure ... –malloc-guard true
If you can use ./configure –sanitize=address, that probably works better. Or - possibly - using valgrind.
On detected errors, this will call std::terminate (); In Debug or Release versions (if you call Debug::RegisterDefaultFatalErrorHandlers ()) - you will get a stack trace dumped and typically a core file - when errors are detected. Though maybe not, since that stuff all allocates memory, and clearly thats not working well when we fail...

Definition at line 70 of file MallocGuard.h.

◆ qStroika_Foundation_Debug_MallocGuard_GuardSize

#define qStroika_Foundation_Debug_MallocGuard_GuardSize   16
qStroika_Foundation_Debug_MallocGuard_GuardSize can be 0, or any integer number greater;
Precondition
qStroika_Foundation_Debug_MallocGuard

Definition at line 79 of file MallocGuard.h.