aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/malloc/api/malloc.cpp
blob: bcfe2b66d86c03196fa384531a1727d2bf7ff5a2 (plain) (blame)
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
#include <stdlib.h> 
#include <stdio.h>

#include "malloc.h"

namespace { 
    bool SetEmptyParam(const char*, const char*) {
        return false; 
    } 
 
    const char* GetEmptyParam(const char*) {
        return nullptr;
    }

    bool CheckEmptyParam(const char*, bool defaultValue) {
        return defaultValue;
    }
} 

namespace NMalloc { 
    volatile bool IsAllocatorCorrupted = false; 
 
    TMallocInfo::TMallocInfo() 
        : Name() 
        , SetParam(SetEmptyParam) 
        , GetParam(GetEmptyParam)
        , CheckParam(CheckEmptyParam)
    { 
    } 

    void AbortFromCorruptedAllocator(const char* errorMessage) {
        errorMessage = errorMessage ? errorMessage : "<unspecified>";
        fprintf(stderr, "Allocator error: %s\n", errorMessage);
        IsAllocatorCorrupted = true;
        abort();
    }
}