1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-09-18 01:33:00 +03:00

Merge PR #608: src/Mayaqua/Memory: remove unused functions

This commit is contained in:
Davide Beatrici 2018-08-05 15:59:38 +02:00 committed by GitHub
commit 20c7ea3432
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 453 deletions

View File

@ -498,7 +498,6 @@ if (kernel_status_inited) { \
#define KS_FREEFIFO_COUNT 37 // Number of times the FIFO object is deleted
#define KS_READ_FIFO_COUNT 38 // Number of calls ReadFifo
#define KS_WRITE_FIFO_COUNT 39 // Number of calls WriteFifo
#define KS_PEEK_FIFO_COUNT 40 // Number of calls PeekFifo
// List related
#define KS_NEWLIST_COUNT 41 // Number of calls NewList
#define KS_FREELIST_COUNT 42 // Number of times the object LIST was deleted

View File

@ -831,18 +831,6 @@ LIST *NewCandidateList()
return NewList(CompareCandidate);
}
// Fill a range of memory
void FillBytes(void *data, UINT size, UCHAR c)
{
UCHAR *buf = (UCHAR *)data;
UINT i;
for (i = 0;i < size;i++)
{
buf[i] = c;
}
}
// Examine whether the specified address points all-zero area
bool IsZero(void *data, UINT size)
{
@ -1116,28 +1104,6 @@ void *Pop(SK *s)
return ret;
}
// Peep
void *PeekQueue(QUEUE *q)
{
void *p = NULL;
// Validate arguments
if (q == NULL)
{
return NULL;
}
if (q->num_item == 0)
{
// No items
return NULL;
}
// Read from the FIFO
PeekFifo(q->fifo, &p, sizeof(void *));
return p;
}
// Get the number of queued items
UINT GetQueueNum(QUEUE *q)
{
@ -1360,36 +1326,6 @@ QUEUE *NewQueueFast()
return q;
}
// Set the comparison function to list
void SetCmp(LIST *o, COMPARE *cmp)
{
// Validate arguments
if (o == NULL || cmp == NULL)
{
return;
}
if (o->cmp != cmp)
{
o->cmp = cmp;
o->sorted = false;
}
}
// Clone the list
LIST *CloneList(LIST *o)
{
LIST *n = NewList(o->cmp);
// Memory reallocation
Free(n->p);
n->p = ToArray(o);
n->num_item = n->num_reserved = LIST_NUM(o);
n->sorted = o->sorted;
return n;
}
// Copy the list to an array
void CopyToArray(LIST *o, void *p)
{
@ -1471,23 +1407,6 @@ void *Search(LIST *o, void *target)
}
}
// Insert an item to the list (Do not insert if it already exists)
void InsertDistinct(LIST *o, void *p)
{
// Validate arguments
if (o == NULL || p == NULL)
{
return;
}
if (IsInList(o, p))
{
return;
}
Insert(o, p);
}
// Insert an item to the list
void Insert(LIST *o, void *p)
{
@ -1566,18 +1485,6 @@ void Insert(LIST *o, void *p)
KS_INC(KS_INSERT_COUNT);
}
// Setting the sort flag
void SetSortFlag(LIST *o, bool sorted)
{
// Validate arguments
if (o == NULL)
{
return;
}
o->sorted = sorted;
}
// Sort the list
void Sort(LIST *o)
{
@ -1593,43 +1500,6 @@ void Sort(LIST *o)
// KS
KS_INC(KS_SORT_COUNT);
}
void SortEx(LIST *o, COMPARE *cmp)
{
// Validate arguments
if (o == NULL)
{
return;
}
qsort(o->p, o->num_item, sizeof(void *), (int(*)(const void *, const void *))cmp);
o->sorted = false;
// KS
KS_INC(KS_SORT_COUNT);
}
// Examine whether a certain string items are present in the list (Unicode version)
bool IsInListUniStr(LIST *o, wchar_t *str)
{
UINT i;
// Validate arguments
if (o == NULL || str == NULL)
{
return false;
}
for (i = 0;i < LIST_NUM(o);i++)
{
wchar_t *s = LIST_DATA(o, i);
if (UniStrCmpi(s, str) == 0)
{
return true;
}
}
return false;
}
// Replace the pointer in the list
bool ReplaceListPointer(LIST *o, void *oldptr, void *newptr)
@ -1785,25 +1655,6 @@ void Add(LIST *o, void *p)
KS_INC(KS_INSERT_COUNT);
}
// Delete the elements specified by the key from the list
bool DeleteKey(LIST *o, UINT key)
{
void *p;
// Validate arguments
if (o == NULL || key == 0)
{
return false;
}
p = ListKeyToPointer(o, key);
if (p == NULL)
{
return false;
}
return Delete(o, p);
}
// Delete the element from the list
bool Delete(LIST *o, void *p)
{
@ -1968,26 +1819,6 @@ bool IsInt64InList(LIST *o, UINT64 i)
return false;
}
// Remove all int from the integer list
void DelAllInt(LIST *o)
{
UINT i;
// Validate arguments
if (o == NULL)
{
return;
}
for (i = 0;i < LIST_NUM(o);i++)
{
UINT *p = LIST_DATA(o, i);
Free(p);
}
DeleteAll(o);
}
// Release the integer list
void ReleaseIntList(LIST *o)
{
@ -2065,44 +1896,6 @@ void DelInt(LIST *o, UINT i)
ReleaseList(o2);
}
}
void DelInt64(LIST *o, UINT64 i)
{
LIST *o2 = NULL;
UINT j;
// Validate arguments
if (o == NULL)
{
return;
}
for (j = 0;j < LIST_NUM(o);j++)
{
UINT64 *p = LIST_DATA(o, j);
if (*p == i)
{
if (o2 == NULL)
{
o2 = NewListFast(NULL);
}
Add(o2, p);
}
}
for (j = 0;j < LIST_NUM(o2);j++)
{
UINT64 *p = LIST_DATA(o2, j);
Delete(o, p);
Free(p);
}
if (o2 != NULL)
{
ReleaseList(o2);
}
}
// Create a new list of integers
LIST *NewIntList(bool sorted)
@ -2154,41 +1947,6 @@ int CompareInt64(void *p1, void *p2)
return COMPARE_RET(*v1, *v2);
}
// Randomize the contents of the list
void RandomizeList(LIST *o)
{
LIST *o2;
UINT i;
// Validate arguments
if (o == NULL)
{
return;
}
o2 = NewListFast(NULL);
while (LIST_NUM(o) != 0)
{
UINT num = LIST_NUM(o);
UINT i = Rand32() % num;
void *p = LIST_DATA(o, i);
Add(o2, p);
Delete(o, p);
}
DeleteAll(o);
for (i = 0;i < LIST_NUM(o2);i++)
{
void *p = LIST_DATA(o2, i);
Add(o, p);
}
ReleaseList(o2);
}
// Add an integer to the list
void AddInt(LIST *o, UINT i)
{
@ -2220,16 +1978,6 @@ void InsertInt(LIST *o, UINT i)
Insert(o, Clone(&i, sizeof(UINT)));
}
void InsertInt64(LIST *o, UINT64 i)
{
// Validate arguments
if (o == NULL)
{
return;
}
Insert(o, Clone(&i, sizeof(UINT64)));
}
// Add an integer to the list (no duplicates)
void AddIntDistinct(LIST *o, UINT i)
@ -2271,19 +2019,6 @@ void InsertIntDistinct(LIST *o, UINT i)
InsertInt(o, i);
}
}
void InsertInt64Distinct(LIST *o, UINT64 i)
{
// Validate arguments
if (o == NULL)
{
return;
}
if (IsInt64InList(o, i) == false)
{
InsertInt64(o, i);
}
}
// String comparison function (Unicode)
int CompareUniStr(void *p1, void *p2)
@ -2406,32 +2141,6 @@ LIST *NewListEx2(COMPARE *cmp, bool fast, bool fast_malloc)
return o;
}
// Peek from the FIFO
UINT PeekFifo(FIFO *f, void *p, UINT size)
{
UINT read_size;
if (f == NULL || size == 0)
{
return 0;
}
// KS
KS_INC(KS_PEEK_FIFO_COUNT);
read_size = MIN(size, f->size);
if (read_size == 0)
{
return 0;
}
if (p != NULL)
{
Copy(p, (UCHAR *)f->p + f->pos, read_size);
}
return read_size;
}
// Read all data from FIFO
BUF *ReadFifoAll(FIFO *f)
{
@ -2528,25 +2237,6 @@ void ShrinkFifoMemory(FIFO *f)
}
}
// Write data to the front of FIFO
void WriteFifoFront(FIFO *f, void *p, UINT size)
{
// Validate arguments
if (f == NULL || size == 0)
{
return;
}
if (f->pos < size)
{
PadFifoFront(f, size - f->pos);
}
Copy(((UCHAR *)f->p) + (f->pos - size), p, size);
f->pos -= size;
f->size += size;
}
// Write to the FIFO
void WriteFifo(FIFO *f, void *p, UINT size)
{
@ -2587,34 +2277,6 @@ void WriteFifo(FIFO *f, void *p, UINT size)
KS_INC(KS_WRITE_FIFO_COUNT);
}
// Add a padding before the head of fifo
void PadFifoFront(FIFO *f, UINT size)
{
// Validate arguments
if (f == NULL || size == 0)
{
return;
}
f->memsize += size;
f->p = ReAlloc(f->p, f->memsize);
}
// Clear the FIFO
void ClearFifo(FIFO *f)
{
// Validate arguments
if (f == NULL)
{
return;
}
f->size = f->pos = 0;
f->memsize = FIFO_INIT_MEM_SIZE;
f->p = ReAlloc(f->p, f->memsize);
}
// Get the current pointer of the FIFO
UCHAR *GetFifoPointer(FIFO *f)
{
@ -2643,30 +2305,6 @@ UINT FifoSize(FIFO *f)
return f->size;
}
// Lock the FIFO
void LockFifo(FIFO *f)
{
// Validate arguments
if (f == NULL)
{
return;
}
Lock(f->lock);
}
// Unlock the FIFO
void UnlockFifo(FIFO *f)
{
// Validate arguments
if (f == NULL)
{
return;
}
Unlock(f->lock);
}
// Release the FIFO
void ReleaseFifo(FIFO *f)
{
@ -2755,12 +2393,6 @@ FIFO *NewFifoEx2(bool fast, bool fixed)
return f;
}
// Get the default memory reclaiming size of the FIFO
UINT GetFifoCurrentReallocMemSize()
{
return fifo_current_realloc_mem_size;
}
// Set the default memory reclaiming size of the FIFO
void SetFifoCurrentReallocMemSize(UINT size)
{
@ -2931,25 +2563,6 @@ bool DumpDataW(void *data, UINT size, wchar_t *filename)
return true;
}
bool DumpData(void *data, UINT size, char *filename)
{
IO *o;
// Validate arguments
if (filename == NULL || (size != 0 && data == NULL))
{
return false;
}
o = FileCreate(filename);
if (o == NULL)
{
return false;
}
FileWrite(o, data, size);
FileClose(o);
return true;
}
// Dump the contents of the buffer to the file
bool DumpBuf(BUF *b, char *filename)
@ -3714,28 +3327,6 @@ UINT64 Endian64(UINT64 src)
}
}
// Swap data of any
void Swap(void *buf, UINT size)
{
UCHAR *tmp, *src;
UINT i;
// Validate arguments
if (buf == NULL || size == 0)
{
return;
}
src = (UCHAR *)buf;
tmp = Malloc(size);
for (i = 0;i < size;i++)
{
tmp[size - i - 1] = src[i];
}
Copy(buf, tmp, size);
Free(buf);
}
// 16bit swap
USHORT Swap16(USHORT value)
{
@ -4263,25 +3854,6 @@ void *AddHead(void *src, UINT src_size, void *head, UINT head_size)
return ret;
}
// Clone the memory area (only the tail)
void *CloneTail(void *src, UINT src_size, UINT dst_size)
{
// Validate arguments
if (src_size != 0 && src == NULL)
{
return NULL;
}
if (src_size >= dst_size)
{
return Clone(((UCHAR *)src) + (src_size - dst_size), dst_size);
}
else
{
return Clone(src, src_size);
}
}
// Clone the memory area
void *Clone(void *addr, UINT size)
{

View File

@ -290,7 +290,6 @@ int CmpCaseIgnore(void *p1, void *p2, UINT size);
void ZeroMem(void *addr, UINT size);
void Zero(void *addr, UINT size);
void *Clone(void *addr, UINT size);
void *CloneTail(void *src, UINT src_size, UINT dst_size);
void *AddHead(void *src, UINT src_size, void *head, UINT head_size);
char B64_CodeToChar(BYTE c);
@ -300,7 +299,6 @@ int B64_Decode(char *set, char *source, int len);
UINT Encode64(char *dst, char *src);
UINT Decode64(char *dst, char *src);
void Swap(void *buf, UINT size);
USHORT Swap16(USHORT value);
UINT Swap32(UINT value);
UINT64 Swap64(UINT64 value);
@ -338,7 +336,6 @@ void AddBufStr(BUF *b, char *str);
bool DumpBuf(BUF *b, char *filename);
bool DumpBufW(BUF *b, wchar_t *filename);
bool DumpBufWIfNecessary(BUF *b, wchar_t *filename);
bool DumpData(void *data, UINT size, char *filename);
bool DumpDataW(void *data, UINT size, wchar_t *filename);
BUF *ReadDump(char *filename);
BUF *ReadDumpWithMaxSize(char *filename, UINT max_size);
@ -351,19 +348,13 @@ BUF *ReadRemainBuf(BUF *b);
UINT ReadBufRemainSize(BUF *b);
bool CompareBuf(BUF *b1, BUF *b2);
UINT PeekFifo(FIFO *f, void *p, UINT size);
UINT ReadFifo(FIFO *f, void *p, UINT size);
BUF *ReadFifoAll(FIFO *f);
void ShrinkFifoMemory(FIFO *f);
UCHAR *GetFifoPointer(FIFO *f);
UCHAR *FifoPtr(FIFO *f);
void WriteFifo(FIFO *f, void *p, UINT size);
void WriteFifoFront(FIFO *f, void *p, UINT size);
void PadFifoFront(FIFO *f, UINT size);
void ClearFifo(FIFO *f);
UINT FifoSize(FIFO *f);
void LockFifo(FIFO *f);
void UnlockFifo(FIFO *f);
void ReleaseFifo(FIFO *f);
void CleanupFifo(FIFO *f);
FIFO *NewFifo();
@ -371,18 +362,14 @@ FIFO *NewFifoFast();
FIFO *NewFifoEx(bool fast);
FIFO *NewFifoEx2(bool fast, bool fixed);
void InitFifo();
UINT GetFifoCurrentReallocMemSize();
void SetFifoCurrentReallocMemSize(UINT size);
void *Search(LIST *o, void *target);
void Sort(LIST *o);
void SortEx(LIST *o, COMPARE *cmp);
void Add(LIST *o, void *p);
void AddDistinct(LIST *o, void *p);
void Insert(LIST *o, void *p);
void InsertDistinct(LIST *o, void *p);
bool Delete(LIST *o, void *p);
bool DeleteKey(LIST *o, UINT key);
void DeleteAll(LIST *o);
void LockList(LIST *o);
void UnlockList(LIST *o);
@ -396,9 +383,6 @@ LIST *NewListSingle(void *p);
void CopyToArray(LIST *o, void *p);
void *ToArray(LIST *o);
void *ToArrayEx(LIST *o, bool fast);
LIST *CloneList(LIST *o);
void SetCmp(LIST *o, COMPARE *cmp);
void SetSortFlag(LIST *o, bool sorted);
int CompareStr(void *p1, void *p2);
bool InsertStr(LIST *o, char *str);
int CompareUniStr(void *p1, void *p2);
@ -406,17 +390,14 @@ bool IsInList(LIST *o, void *p);
bool IsInListKey(LIST *o, UINT key);
void *ListKeyToPointer(LIST *o, UINT key);
bool IsInListStr(LIST *o, char *str);
bool IsInListUniStr(LIST *o, wchar_t *str);
bool ReplaceListPointer(LIST *o, void *oldptr, void *newptr);
void AddInt(LIST *o, UINT i);
void AddInt64(LIST *o, UINT64 i);
void AddIntDistinct(LIST *o, UINT i);
void AddInt64Distinct(LIST *o, UINT64 i);
void DelInt(LIST *o, UINT i);
void DelInt64(LIST *o, UINT64 i);
void ReleaseIntList(LIST *o);
void ReleaseInt64List(LIST *o);
void DelAllInt(LIST *o);
bool IsIntInList(LIST *o, UINT i);
bool IsInt64InList(LIST *o, UINT64 i);
LIST *NewIntList(bool sorted);
@ -424,14 +405,10 @@ LIST *NewInt64List(bool sorted);
int CompareInt(void *p1, void *p2);
int CompareInt64(void *p1, void *p2);
void InsertInt(LIST *o, UINT i);
void InsertInt64(LIST *o, UINT64 i);
void InsertIntDistinct(LIST *o, UINT i);
void InsertInt64Distinct(LIST *o, UINT64 i);
void RandomizeList(LIST *o);
void *GetNext(QUEUE *q);
void *GetNextWithLock(QUEUE *q);
void *PeekQueue(QUEUE *q);
void InsertQueue(QUEUE *q, void *p);
void InsertQueueWithLock(QUEUE *q, void *p);
void InsertQueueInt(QUEUE *q, UINT value);
@ -460,7 +437,6 @@ BUF *CompressBuf(BUF *src_buf);
BUF *UncompressBuf(BUF *src_buf);
bool IsZero(void *data, UINT size);
void FillBytes(void *data, UINT size, UCHAR c);
LIST *NewStrMap();
void *StrMapSearch(LIST *map, char *key);