aboutsummaryrefslogblamecommitdiffstats
path: root/library/cpp/malloc/api/malloc.cpp
blob: eed1c58a383ce2b4b3321a42c0e9b323c0cc5e43 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                   
                  
 
                   
           
                                                  

                     
                                            

                       
                                                          
                            
 
 




                                               
                                 
                                     
     
 

                                                                     

                                    
 
#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();
    }
}