aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/malloc/api/malloc.h
blob: 9df6f0c7cf1a3fa41d7144090507e79500604bad (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;
        }
    };
}