Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/SoftEtherVPN/SoftEtherVPN_Stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordnobori <da.git@softether.co.jp>2014-06-06 01:53:20 +0400
committerdnobori <da.git@softether.co.jp>2014-06-06 01:53:20 +0400
commit719ee999d6c6418b3e9f4afb904387700637009f (patch)
treec337288d68f4a129053d098f1f64269c699a4490 /src/Mayaqua/Memory.c
parent7839d2939e5336bdf492041f1c2ed564444d7a62 (diff)
v4.07-9448-rtm
Diffstat (limited to 'src/Mayaqua/Memory.c')
-rw-r--r--src/Mayaqua/Memory.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/Mayaqua/Memory.c b/src/Mayaqua/Memory.c
index 4c953d57..709da118 100644
--- a/src/Mayaqua/Memory.c
+++ b/src/Mayaqua/Memory.c
@@ -2005,6 +2005,41 @@ 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)
{