The following code will make a memory error when closing a steam dedicated server and I have no clue why.
There is no error while running the code either
Code:
#include <sourcemod>
public OnPluginStart()
{
new Handle:value = CreateArray(1)
// 0,0,1,0,0,1,0
PushArrayCell(value, 0)
PushArrayCell(value, 0)
PushArrayCell(value, 1)
PushArrayCell(value, 0)
PushArrayCell(value, 0)
PushArrayCell(value, 1)
PushArrayCell(value, 0)
MergeSortMaps(value, 0, GetArraySize(value)-1 )
CloseHandle(value)
}
/*
sort maps after its value hence several lists
*/
MergeSortMaps( Handle:valueList, startIndex, endIndex )
{
// base case
if( startIndex == endIndex )
{
return
}
// sort each half
new startIndex2 = (startIndex + endIndex) / 2
MergeSortMaps( valueList, startIndex, startIndex2 )
startIndex2++
MergeSortMaps( valueList, startIndex2, endIndex)
// merge the two sorted halves
new tempValue
while( startIndex < startIndex2 && startIndex2 <= endIndex )
{
if( GetArrayCell(valueList, startIndex) > GetArrayCell(valueList, startIndex2) )
{
tempValue = GetArrayCell(valueList, startIndex2)
RemoveFromArray(valueList, startIndex2)
ShiftArrayUp(valueList, startIndex)
SetArrayCell(valueList, startIndex, tempValue)
startIndex2++
}
startIndex++
}
}