diff --git a/core/logic/smn_sorting.cpp b/core/logic/smn_sorting.cpp index 94831d49..084453f3 100644 --- a/core/logic/smn_sorting.cpp +++ b/core/logic/smn_sorting.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include "common_logic.h" #include "CellArray.h" #include @@ -227,16 +228,10 @@ static cell_t sm_SortStrings_Legacy(IPluginContext *pContext, const cell_t *para pContext->LocalToPhysAddr(params[1], &array); /** HACKHACK - back up the old indices, replace the indices with something easier */ - cell_t amx_addr, *phys_addr; - int err; - if ((err=pContext->HeapAlloc(array_size, &amx_addr, &phys_addr)) != SP_ERROR_NONE) - { - pContext->ThrowNativeErrorEx(err, "Ran out of memory to sort"); - return 0; - } + auto phys_addr = std::make_unique(array_size); g_CurStringArray = array; - g_CurRebaseMap = phys_addr; + g_CurRebaseMap = phys_addr.get(); for (int i=0; iHeapPop(amx_addr); - g_CurStringArray = NULL; g_CurRebaseMap = NULL; @@ -449,13 +442,7 @@ static cell_t sm_SortCustom2D_Legacy(IPluginContext *pContext, const cell_t *par } /** back up the old indices, replace the indices with something easier */ - cell_t amx_addr, *phys_addr; - int err; - if ((err=pContext->HeapAlloc(array_size, &amx_addr, &phys_addr)) != SP_ERROR_NONE) - { - pContext->ThrowNativeErrorEx(err, "Ran out of memory to sort"); - return 0; - } + auto phys_addr = std::make_unique(array_size); sort_info oldinfo = g_SortInfo; @@ -467,7 +454,7 @@ static cell_t sm_SortCustom2D_Legacy(IPluginContext *pContext, const cell_t *par /** Same process as in strings, back up the old indices for later fixup */ g_SortInfo.array_base = array; - g_SortInfo.array_remap = phys_addr; + g_SortInfo.array_remap = phys_addr.get(); for (int i=0; iHeapPop(amx_addr); - g_SortInfo = oldinfo; return 1; diff --git a/sourcepawn b/sourcepawn index 48d6c5d0..40ace9d7 160000 --- a/sourcepawn +++ b/sourcepawn @@ -1 +1 @@ -Subproject commit 48d6c5d0aa3b4fcb75a013803de5d5ab28e4bf7e +Subproject commit 40ace9d79b1ce02d714b17b5f377b0a27a5f2eab