1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-25 19:09:52 +03:00

Memory: restore CloneList() function which was removed in #608

This commit is contained in:
Davide Beatrici 2018-08-05 17:26:37 +02:00
parent 59e1483dbf
commit 190ad01eb7
2 changed files with 15 additions and 0 deletions

View File

@ -1326,6 +1326,20 @@ QUEUE *NewQueueFast()
return q;
}
// 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)
{

View File

@ -380,6 +380,7 @@ LIST *NewListFast(COMPARE *cmp);
LIST *NewListEx(COMPARE *cmp, bool fast);
LIST *NewListEx2(COMPARE *cmp, bool fast, bool fast_malloc);
LIST *NewListSingle(void *p);
LIST *CloneList(LIST *o);
void CopyToArray(LIST *o, void *p);
void *ToArray(LIST *o);
void *ToArrayEx(LIST *o, bool fast);