forked from RetiredC/Kang-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.h
58 lines (48 loc) · 1.03 KB
/
utils.h
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// (c) 2024, RetiredCoder
// License: GPLv3, see "LICENSE.TXT" file
// https://github.com/RetiredC/Kang-1
#pragma once
#include <Windows.h>
#include <stdio.h>
#include <vector>
#include "defs.h"
class TMemPool
{
private:
std::vector <BYTE*> mems;
int MemBlockSize;
size_t pnt;
public:
TMemPool();
~TMemPool();
BYTE* GetMem(size_t size);
void Init(int _MemBlockSize);
void Clear();
};
struct TListRec
{
unsigned int cnt;
unsigned int capacity;
void** data;
};
class TFastBase
{
private:
TMemPool mempool;
int FindSize;
TListRec lists[256][256];
int BaseRecSize;
int AdvRecOffset;
int AdvRecSize;
int lower_bound(TListRec* list, BYTE* data);
bool IsEmpty;
public:
TFastBase();
~TFastBase();
void Init(int _FindSize, int _BaseRecSize, int _AdvRecOffset, int _AdvRecSize);
void Clear(bool all);
BYTE* AddDataBlock(BYTE* data, int datalen, int pos = -1);
BYTE* FindDataBlock(BYTE* data);
BYTE* FindOrAddDataBlock(BYTE* data, int datalen);
int GetBlockCnt();
};