aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/malloc/api/malloc.h
blob: bd9300aede7b9cdcdc2ae94266ffec3dcd5f0df0 (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
#pragma once

#include <string.h>
#include <util/system/compiler.h> 

namespace NMalloc {
    struct TMallocInfo {
        TMallocInfo();

        const char* Name;

        bool (*SetParam)(const char* param, const char* value);
        const char* (*GetParam)(const char* param);

        bool (*CheckParam)(const char* param, bool defaultValue);
    };

    extern volatile bool IsAllocatorCorrupted;
    void AbortFromCorruptedAllocator(const char* errorMessage = nullptr);

    // this function should be implemented by malloc implementations
    TMallocInfo MallocInfo();
 
    struct TAllocHeader { 
        void* Block; 
        size_t AllocSize; 
        void Y_FORCE_INLINE Encode(void* block, size_t size, size_t signature) { 
            Block = block; 
            AllocSize = size | signature; 
        } 
    }; 
}