diff --git a/include/memory.inc b/include/memory.inc
index 293a508..1245f08 100644
--- a/include/memory.inc
+++ b/include/memory.inc
@@ -39,19 +39,19 @@ enum EMemoryResult
EMemoryResult_OutOfMemory
}
-// Allocate new memory. Delete with `MEM_delete`
+// Allocate new memory. Delete with "MEM_delete"
native Pointer:MEM_new(cells = 1);
-// Allocate new zeroed memory. Delete with `MEM_delete`
+// Allocate new zeroed memory. Delete with "MEM_delete"
native Pointer:MEM_new_zero(cells = 1);
-// Allocate new value. Delete with `MEM_delete`
+// Allocate new value. Delete with "MEM_delete"
native Pointer:MEM_new_val(value);
-// Allocate new array. Delete with `MEM_delete`
+// Allocate new array. Delete with "MEM_delete"
native Pointer:MEM_new_arr(const arr[], arr_size = sizeof arr);
-// Clone memory. Delete with `MEM_delete`
+// Clone memory. Delete with "MEM_delete"
native Pointer:MEM_clone(Pointer:pointer);
// Delete allocated memory
@@ -84,34 +84,34 @@ native Pointer:MEM_zero(Pointer:pointer, size, index = 0);
// Get last result
native EMemoryResult:MEM_get_last_result();
-// Allocate new unmanaged memory. Delete with `MEM_UM_delete`
+// Allocate new unmanaged memory. Delete with "MEM_UM_delete"
native UnmanagedPointer:MEM_UM_new(cells = 1);
-// Allocate new zeroed unmanaged memory. Delete with `MEM_UM_delete`
+// Allocate new zeroed unmanaged memory. Delete with "MEM_UM_delete"
native UnmanagedPointer:MEM_UM_new_zero(cells = 1);
-// Allocate new unmanaged value. Delete with `MEM_UM_delete`
+// Allocate new unmanaged value. Delete with "MEM_UM_delete"
native UnmanagedPointer:MEM_UM_new_val(value);
-// Allocate new unmanaged array. Delete with `MEM_UM_delete`
+// Allocate new unmanaged array. Delete with "MEM_UM_delete"
native UnmanagedPointer:MEM_UM_new_arr(const arr[], arr_size = sizeof arr);
-// Clone unmanaged memory. Delete with `MEM_UM_delete`
+// Clone unmanaged memory. Delete with "MEM_UM_delete"
native UnmanagedPointer:MEM_UM_clone(AnyPointer:pointer, index = 0, cells);
// Delete unmanaged memory
native MEM_UM_delete(UnmanagedPointer:pointer);
-// Get unmanaged value
+// Get value from unmanaged memory
native MEM_UM_get_val(AnyPointer:pointer, index = 0);
-// Get unmanaged array
+// Get array from unmanaged memory
native ForeignPointer:MEM_UM_get_arr(AnyPointer:pointer, index = 0, arr[], arr_size = sizeof arr);
-// Set unmanaged value
+// Set value at unmanaged memory
native MEM_UM_set_val(UnmanagedPointer:pointer, index = 0, value);
-// Set unmanaged array
+// Set array at unmanaged memory
native ForeignPointer:MEM_UM_set_arr(UnmanagedPointer:pointer, index = 0, const arr[], arr_size = sizeof arr);
// Copy unmanaged memory
diff --git a/pawn-memory/EMemoryResult.h b/pawn-memory/EMemoryResult.h
index 28e8c38..c207b0e 100644
--- a/pawn-memory/EMemoryResult.h
+++ b/pawn-memory/EMemoryResult.h
@@ -1,28 +1,44 @@
#ifndef __PAWN_MEMORY_E_MEMORY_RESULT_H__
# define __PAWN_MEMORY_E_MEMORY_RESULT_H__
-// PAWN memory namespace
+///
+/// PAWN memory namespace
+///
namespace PAWNMemory
{
- // Memory result enumerator
+ ///
+ /// Memory result enumerator
+ ///
enum EMemoryResult
{
- // OK
+ ///
+ /// OK
+ ///
EMemoryResult_OK,
- // Invalid size
+ ///
+ /// Invalid size
+ ///
EMemoryResult_InvalidSize,
- // Invalid pointer
+ ///
+ /// Invalid pointer
+ ///
EMemoryResult_InvalidPointer,
- // Invalid index
+ ///
+ /// Invalid index
+ ///
EMemoryResult_InvalidIndex,
- // Invalid index and size
+ ///
+ /// Invalid index and size
+ ///
EMemoryResult_InvalidIndexSize,
- // Out of memory
+ ///
+ /// Out of memory
+ ///
EMemoryResult_OutOfMemory
};
}
diff --git a/pawn-memory/ManagedMemory.cpp b/pawn-memory/ManagedMemory.cpp
index ae062ba..2e4a8b0 100644
--- a/pawn-memory/ManagedMemory.cpp
+++ b/pawn-memory/ManagedMemory.cpp
@@ -1,13 +1,24 @@
#include "ManagedMemory.h"
#include
-using namespace PAWNMemory;
using namespace std;
+using namespace PAWNMemory;
+///
+/// Pointers
+///
map ManagedMemory::pointers;
+///
+/// Last result
+///
EMemoryResult ManagedMemory::lastResult(EMemoryResult_OK);
+///
+/// New
+///
+/// Size
+/// Pointer of allocated memory if successful, otherwise "nullptr"
cell * ManagedMemory::New(cell size)
{
cell *ret(nullptr);
@@ -39,6 +50,11 @@ cell * ManagedMemory::New(cell size)
return ret;
}
+///
+/// New zero
+///
+/// Size
+/// Pointer of allocated memory if successful, otherwise "nullptr"
cell * ManagedMemory::NewZero(cell size)
{
cell *ret(nullptr);
@@ -71,6 +87,11 @@ cell * ManagedMemory::NewZero(cell size)
return ret;
}
+///
+/// New value
+///
+/// Value
+/// Pointer of allocated memory if successful, otherwise "nullptr"
cell * ManagedMemory::NewValue(cell val)
{
cell *ret(nullptr);
@@ -96,6 +117,12 @@ cell * ManagedMemory::NewValue(cell val)
return ret;
}
+///
+/// New array
+///
+/// Array
+/// Size
+/// Pointer of allocated memory if successful, otherwise "nullptr"
cell * ManagedMemory::NewArray(cell * arr, cell size)
{
cell *ret(nullptr);
@@ -128,6 +155,11 @@ cell * ManagedMemory::NewArray(cell * arr, cell size)
return ret;
}
+///
+/// Clone
+///
+/// Pointer
+/// Pointer of allocated memory if successful, otherwise "nullptr"
cell * ManagedMemory::Clone(cell * ptr)
{
cell *ret(nullptr);
@@ -161,6 +193,10 @@ cell * ManagedMemory::Clone(cell * ptr)
return ret;
}
+///
+/// Delete
+///
+/// Pointer
void ManagedMemory::Delete(cell * ptr)
{
map::iterator it(pointers.find(ptr));
@@ -176,12 +212,22 @@ void ManagedMemory::Delete(cell * ptr)
}
}
+///
+/// Is valid pointer
+///
+/// Pointer
+/// "true" if pointer is valid, otherwise "false"
bool ManagedMemory::IsValidPointer(cell * ptr)
{
lastResult = EMemoryResult_OK;
return (pointers.find(ptr) != pointers.end());
}
+///
+/// Get size
+///
+/// Pointer
+/// Size of allocated memory
cell ManagedMemory::GetSize(cell * ptr)
{
cell ret(0);
@@ -198,6 +244,9 @@ cell ManagedMemory::GetSize(cell * ptr)
return ret;
}
+///
+/// Clear
+///
void ManagedMemory::Clear()
{
for (pair pointer : pointers)
@@ -208,6 +257,10 @@ void ManagedMemory::Clear()
lastResult = EMemoryResult_OK;
}
+///
+/// Get last result
+///
+/// Last result
EMemoryResult ManagedMemory::GetLastResult()
{
EMemoryResult ret(lastResult);
diff --git a/pawn-memory/ManagedMemory.h b/pawn-memory/ManagedMemory.h
index e0a6548..efe0aac 100644
--- a/pawn-memory/ManagedMemory.h
+++ b/pawn-memory/ManagedMemory.h
@@ -7,62 +7,118 @@
# include "SDK/plugin.h"
# include "EMemoryResult.h"
-// PAWN memory namespace
+///
+/// PAWN memory namespace
+///
namespace PAWNMemory
{
- // Managed memory class
+ ///
+ /// Managed memory class
+ ///
class ManagedMemory
{
private:
- // Pointers
+ ///
+ /// Pointers
+ ///
static std::map pointers;
- // Last result
+ ///
+ /// Last result
+ ///
static EMemoryResult lastResult;
- // Default constructor
+ ///
+ /// Default constructor
+ ///
ManagedMemory();
- // Copy constructor
+ ///
+ /// Copy constructor
+ ///
+ ///
ManagedMemory(const ManagedMemory &);
- // Destructor
+ ///
+ /// Destructor
+ ///
~ManagedMemory();
- // Assign operator
+ ///
+ /// Assign operator
+ ///
+ ///
+ /// This object
ManagedMemory & operator = (const ManagedMemory &);
public:
- // New
+ ///
+ /// New
+ ///
+ /// Size
+ /// Pointer of allocated memory if successful, otherwise "nullptr"
static cell *New(cell size);
- // New zero
+ ///
+ /// New zero
+ ///
+ /// Size
+ /// Pointer of allocated memory if successful, otherwise "nullptr"
static cell *NewZero(cell size);
- // New value
+ ///
+ /// New value
+ ///
+ /// Value
+ /// Pointer of allocated memory if successful, otherwise "nullptr"
static cell *NewValue(cell val);
- // New array
+ ///
+ /// New array
+ ///
+ /// Array
+ /// Size
+ /// Pointer of allocated memory if successful, otherwise "nullptr"
static cell *NewArray(cell * arr, cell size);
- // Clone
+ ///
+ /// Clone
+ ///
+ /// Pointer
+ /// Pointer of allocated memory if successful, otherwise "nullptr"
static cell *Clone(cell * ptr);
- // Delete
+ ///
+ /// Delete
+ ///
+ /// Pointer
static void Delete(cell * ptr);
- // Is valid pointer
+ ///
+ /// Is valid pointer
+ ///
+ /// Pointer
+ /// "true" if pointer is valid, otherwise "false"
static bool IsValidPointer(cell * ptr);
- // Get size
+ ///
+ /// Get size
+ ///
+ /// Pointer
+ /// Size of allocated memory
static cell GetSize(cell * ptr);
- // Clear
+ ///
+ /// Clear
+ ///
static void Clear();
- // Get last result
+ ///
+ /// Get last result
+ ///
+ /// Last result
static EMemoryResult GetLastResult();
};
}
diff --git a/pawn-memory/main.cpp b/pawn-memory/main.cpp
index 691ff24..d1aa4cc 100644
--- a/pawn-memory/main.cpp
+++ b/pawn-memory/main.cpp
@@ -5,17 +5,25 @@
#include "ManagedMemory.h"
#include
-using namespace PAWNMemory;
using namespace std;
+using namespace PAWNMemory;
typedef void(*logprintf_t)(char *format, ...);
logprintf_t logprintf;
extern void *pAMXFunctions;
-// Last result
+///
+/// Last result
+///
static EMemoryResult lastResult(EMemoryResult_OK);
-// Number of arguments are equal
+///
+/// Number of arguments are equal
+///
+/// Params
+/// Expected count of params
+/// FUnction name
+/// "true if number of params match with expected count of params, otherwise "false"
inline bool NumArgsEqual(cell *params, cell expectedCount, const char *functionName)
{
@@ -27,7 +35,13 @@ inline bool NumArgsEqual(cell *params, cell expectedCount, const char *functionN
return ret;
}
-// Pointer:MEM_new(cells = 1)
+///
+/// Allocate new memory. Delete with "MEM_delete"
+///
+/// AMX
+/// Params
+/// Pointer of allocated memory if successful, otherwise "MEM_NULLPTR"
+/// Pointer:MEM_new(cells = 1)
cell AMX_NATIVE_CALL AMX_MEM_new(AMX *amx, cell *params)
{
cell *ret(nullptr);
@@ -39,7 +53,13 @@ cell AMX_NATIVE_CALL AMX_MEM_new(AMX *amx, cell *params)
return reinterpret_cast(ret);
}
-// Pointer:MEM_new_zero(cells = 1)
+///
+/// Allocate new zeroed memory. Delete with "MEM_delete"
+///
+/// AMX
+/// Params
+/// Pointer of allocated memory if successful, otherwise "MEM_NULLPTR"
+/// Pointer:MEM_new_zero(cells = 1)
cell AMX_NATIVE_CALL AMX_MEM_new_zero(AMX *amx, cell *params)
{
cell *ret(nullptr);
@@ -51,7 +71,13 @@ cell AMX_NATIVE_CALL AMX_MEM_new_zero(AMX *amx, cell *params)
return reinterpret_cast(ret);
}
-// Pointer:MEM_new_val(value)
+///
+/// Allocate new value. Delete with "MEM_delete"
+///
+/// AMX
+/// Params
+/// Pointer of allocated memory if successful, otherwise "MEM_NULLPTR"
+/// Pointer:MEM_new_val(value)
cell AMX_NATIVE_CALL AMX_MEM_new_val(AMX *amx, cell *params)
{
cell *ret(nullptr);
@@ -63,7 +89,13 @@ cell AMX_NATIVE_CALL AMX_MEM_new_val(AMX *amx, cell *params)
return reinterpret_cast(ret);
}
-// Pointer:MEM_new_arr(const arr[], arr_size = sizeof arr)
+///
+/// Allocate new array. Delete with "MEM_delete"
+///
+/// AMX
+/// Params
+/// Pointer of allocated memory if successful, otherwise "MEM_NULLPTR"
+/// Pointer:MEM_new_arr(const arr[], arr_size = sizeof arr)
cell AMX_NATIVE_CALL AMX_MEM_new_arr(AMX *amx, cell *params)
{
cell *ret(nullptr);
@@ -77,7 +109,13 @@ cell AMX_NATIVE_CALL AMX_MEM_new_arr(AMX *amx, cell *params)
return reinterpret_cast(ret);
}
-// Pointer:MEM_clone(Pointer:pointer)
+///
+/// Clone memory. Delete with "MEM_delete"
+///
+/// AMX
+/// Params
+/// Pointer of allocated memory if successful, otherwise "MEM_NULLPTR"
+/// Pointer:MEM_clone(Pointer:pointer)
cell AMX_NATIVE_CALL AMX_MEM_clone(AMX *amx, cell *params)
{
cell *ret(nullptr);
@@ -89,7 +127,13 @@ cell AMX_NATIVE_CALL AMX_MEM_clone(AMX *amx, cell *params)
return reinterpret_cast(ret);
}
-// MEM_delete(Pointer:pointer)
+///
+/// Delete allocated memory
+///
+/// AMX
+/// Params
+/// Nothing
+/// MEM_delete(Pointer:pointer)
cell AMX_NATIVE_CALL AMX_MEM_delete(AMX *amx, cell *params)
{
if (NumArgsEqual(params, 1, "MEM_delete"))
@@ -100,7 +144,13 @@ cell AMX_NATIVE_CALL AMX_MEM_delete(AMX *amx, cell *params)
return 0;
}
-// bool:MEM_is_valid_ptr(Pointer:pointer)
+///
+/// Is valid pointer
+///
+/// AMX
+/// Params
+/// "true" if pointer is valid, otherwise "false"
+/// bool:MEM_is_valid_ptr(Pointer:pointer)
cell AMX_NATIVE_CALL AMX_MEM_is_valid_ptr(AMX *amx, cell *params)
{
bool ret(false);
@@ -112,7 +162,13 @@ cell AMX_NATIVE_CALL AMX_MEM_is_valid_ptr(AMX *amx, cell *params)
return ret;
}
-// MEM_get_size(Pointer:pointer)
+///
+/// Get size
+///
+/// AMX
+/// Params
+/// Size in cells of allocated memory if successful, otherwise "0"
+/// MEM_get_size(Pointer:pointer)
cell AMX_NATIVE_CALL AMX_MEM_get_size(AMX *amx, cell *params)
{
cell ret(0);
@@ -124,7 +180,13 @@ cell AMX_NATIVE_CALL AMX_MEM_get_size(AMX *amx, cell *params)
return ret;
}
-// MEM_get_val(Pointer:pointer, index = 0)
+///
+/// Get value
+///
+/// AMX
+/// Params
+/// Value from allocated memory if successful, otherwise "0"
+/// MEM_get_val(Pointer:pointer, index = 0)
cell AMX_NATIVE_CALL AMX_MEM_get_val(AMX *amx, cell *params)
{
cell ret(0);
@@ -134,17 +196,10 @@ cell AMX_NATIVE_CALL AMX_MEM_get_val(AMX *amx, cell *params)
cell size(ManagedMemory::GetSize(ptr));
if (size > 0)
{
- if (params[2] >= 0)
+ if ((params[2] >= 0) && (params[2] < size))
{
- if (params[2] < size)
- {
- ret = ptr[params[2]];
- lastResult = EMemoryResult_OK;
- }
- else
- {
- lastResult = EMemoryResult_InvalidIndex;
- }
+ ret = ptr[params[2]];
+ lastResult = EMemoryResult_OK;
}
else
{
@@ -159,7 +214,13 @@ cell AMX_NATIVE_CALL AMX_MEM_get_val(AMX *amx, cell *params)
return ret;
}
-// ForeignPointer:MEM_get_arr(Pointer:pointer, index = 0, arr[], arr_size = sizeof arr)
+///
+/// Get array
+///
+/// AMX
+/// Params
+/// Pointer of array if successful, otherwise "MEM_NULLFEPTR"
+/// ForeignPointer:MEM_get_arr(Pointer:pointer, index = 0, arr[], arr_size = sizeof arr)
cell AMX_NATIVE_CALL AMX_MEM_get_arr(AMX *amx, cell *params)
{
cell *ret(nullptr);
@@ -170,11 +231,18 @@ cell AMX_NATIVE_CALL AMX_MEM_get_arr(AMX *amx, cell *params)
{
if (params[2] >= 0)
{
- if ((params[4] > 0) && ((params[4] + params[2]) <= size))
+ if (params[4] > 0)
{
- amx_GetAddr(amx, params[3], &ret);
- memcpy(ret, reinterpret_cast(params[1] + (params[2] * sizeof(cell))), params[4] * sizeof(cell));
- lastResult = EMemoryResult_OK;
+ if ((params[4] + params[2]) <= size)
+ {
+ amx_GetAddr(amx, params[3], &ret);
+ memcpy(ret, reinterpret_cast(params[1] + (params[2] * sizeof(cell))), params[4] * sizeof(cell));
+ lastResult = EMemoryResult_OK;
+ }
+ else
+ {
+ lastResult = EMemoryResult_InvalidIndexSize;
+ }
}
else
{
@@ -194,7 +262,13 @@ cell AMX_NATIVE_CALL AMX_MEM_get_arr(AMX *amx, cell *params)
return reinterpret_cast(ret);
}
-// MEM_set_val(Pointer:pointer, index = 0, value)
+///
+/// Set value
+///
+/// AMX
+/// Params
+/// Value if successful, otherwise "0"
+/// MEM_set_val(Pointer:pointer, index = 0, value)
cell AMX_NATIVE_CALL AMX_MEM_set_val(AMX *amx, cell *params)
{
cell ret(0);
@@ -204,9 +278,16 @@ cell AMX_NATIVE_CALL AMX_MEM_set_val(AMX *amx, cell *params)
cell size(ManagedMemory::GetSize(ptr));
if (size > 0)
{
- ptr[params[2]] = params[3];
- ret = params[3];
- lastResult = EMemoryResult_OK;
+ if ((params[2] >= 0) && (params[2] < size))
+ {
+ ptr[params[2]] = params[3];
+ ret = params[3];
+ lastResult = EMemoryResult_OK;
+ }
+ else
+ {
+ lastResult = EMemoryResult_InvalidIndex;
+ }
}
else
{
@@ -216,41 +297,61 @@ cell AMX_NATIVE_CALL AMX_MEM_set_val(AMX *amx, cell *params)
return ret;
}
-// UnmanagedPointer:MEM_set_arr(Pointer:pointer, index = 0, const arr[], arr_size = sizeof arr)
+///
+/// Set array
+///
+/// AMX
+/// Params
+/// Pointer of array if successful, otherwise "MEM_NULLFEPTR"
+/// ForeignPointer:MEM_set_arr(Pointer:pointer, index = 0, const arr[], arr_size = sizeof arr)
cell AMX_NATIVE_CALL AMX_MEM_set_arr(AMX *amx, cell *params)
{
cell *ret(nullptr);
- if (NumArgsEqual(params, 4, "MEM_set_val"))
+ if (NumArgsEqual(params, 4, "MEM_set_arr"))
{
- if (params[2] >= 0)
+ cell size(ManagedMemory::GetSize(reinterpret_cast(params[1])));
+ if (size > 0)
{
- if (params[4] > 0)
+ if ((params[2] >= 0) && (params[2] < params[4]))
{
- if (params[2] < params[4])
+ if (params[4] > 0)
{
- amx_GetAddr(amx, params[3], &ret);
- memcpy(reinterpret_cast(params[1] + (params[2] * sizeof(cell))), ret, params[4] * sizeof(cell));
- lastResult = EMemoryResult_OK;
+ if ((params[4] + params[2]) <= size)
+ {
+ amx_GetAddr(amx, params[3], &ret);
+ memcpy(reinterpret_cast(params[1] + (params[2] * sizeof(cell))), ret, params[4] * sizeof(cell));
+ lastResult = EMemoryResult_OK;
+ }
+ else
+ {
+ lastResult = EMemoryResult_InvalidIndexSize;
+ }
}
else
{
- lastResult = EMemoryResult_InvalidIndex;
+ lastResult = EMemoryResult_InvalidSize;
}
}
else
{
- lastResult = EMemoryResult_InvalidSize;
+ lastResult = EMemoryResult_InvalidIndex;
}
}
else
{
- lastResult = EMemoryResult_InvalidIndex;
+ lastResult = ManagedMemory::GetLastResult();
}
}
return reinterpret_cast(ret);
}
-// Pointer:MEM_copy(Pointer:dest, Pointer:src, size, dest_index = 0, src_index = 0)
+///
+/// Copy memory
+///
+/// AMX
+/// Params
+/// Pointer of destination if successful, otherwise "MEM_NULLPTR"
+/// Pointer:MEM_copy(Pointer:dest, Pointer:src, size, dest_index = 0, src_index = 0)
cell AMX_NATIVE_CALL AMX_MEM_copy(AMX *amx, cell *params)
{
cell *ret(nullptr);
@@ -292,7 +393,13 @@ cell AMX_NATIVE_CALL AMX_MEM_copy(AMX *amx, cell *params)
return reinterpret_cast(ret);
}
-// Pointer:MEM_zero(Pointer:pointer, size, index = 0)
+///
+/// Zero memory
+///
+/// AMX
+/// Params
+/// Pointer of destination if successful, otherwise "MEM_NULLPTR"
+/// Pointer:MEM_zero(Pointer:pointer, size, index = 0)
cell AMX_NATIVE_CALL AMX_MEM_zero(AMX *amx, cell *params)
{
cell *ret(nullptr);
@@ -333,7 +440,13 @@ cell AMX_NATIVE_CALL AMX_MEM_zero(AMX *amx, cell *params)
return reinterpret_cast(ret);
}
-// EMemoryResult:MEM_get_last_result()
+///
+/// Get last result
+///
+/// AMX
+/// Params
+/// Last result
+/// EMemoryResult:MEM_get_last_result()
cell AMX_NATIVE_CALL AMX_MEM_get_last_result(AMX *amx, cell *params)
{
EMemoryResult ret(lastResult);
@@ -341,7 +454,13 @@ cell AMX_NATIVE_CALL AMX_MEM_get_last_result(AMX *amx, cell *params)
return ret;
}
-// UnmanagedPointer:MEM_UM_new(cells = 1)
+///
+/// Allocate new unmanaged memory. Delete with "MEM_UM_delete"
+///
+/// AMX
+/// Params
+/// Pointer of allocated memory if successful, otherwise "MEM_NULLUMPTR"
+/// UnmanagedPointer:MEM_UM_new(cells = 1)
cell AMX_NATIVE_CALL AMX_MEM_UM_new(AMX *amx, cell *params)
{
cell *ret(nullptr);
@@ -352,14 +471,7 @@ cell AMX_NATIVE_CALL AMX_MEM_UM_new(AMX *amx, cell *params)
try
{
ret = new cell[params[1]];
- if (ret != nullptr)
- {
- lastResult = EMemoryResult_OK;
- }
- else
- {
- lastResult = EMemoryResult_OutOfMemory;
- }
+ lastResult = (ret ? EMemoryResult_OK : EMemoryResult_OutOfMemory);
}
catch (...)
{
@@ -375,7 +487,13 @@ cell AMX_NATIVE_CALL AMX_MEM_UM_new(AMX *amx, cell *params)
return reinterpret_cast(ret);
}
-// UnmanagedPointer:MEM_UM_new_zero(cells = 1)
+///
+/// Allocate new zeroed unmanaged memory. Delete with "MEM_UM_delete"
+///
+/// AMX
+/// Params
+/// Pointer of allocated memory if successful, otherwise "MEM_NULLUMPTR"
+/// UnmanagedPointer:MEM_UM_new_zero(cells = 1)
cell AMX_NATIVE_CALL AMX_MEM_UM_new_zero(AMX *amx, cell *params)
{
cell *ret(nullptr);
@@ -410,7 +528,13 @@ cell AMX_NATIVE_CALL AMX_MEM_UM_new_zero(AMX *amx, cell *params)
return reinterpret_cast(ret);
}
-// UnmanagedPointer:MEM_UM_new_val(value)
+///
+/// Allocate new unmanaged value. Delete with "MEM_UM_delete"
+///
+/// AMX
+/// Params
+/// Pointer of allocated memory if successful, otherwise "MEM_NULLUMPTR"
+/// UnmanagedPointer:MEM_UM_new_val(value)
cell AMX_NATIVE_CALL AMX_MEM_UM_new_val(AMX *amx, cell *params)
{
cell *ret(nullptr);
@@ -438,7 +562,13 @@ cell AMX_NATIVE_CALL AMX_MEM_UM_new_val(AMX *amx, cell *params)
return reinterpret_cast(ret);
}
-// UnmanagedPointer:MEM_UM_new_arr(const arr[], arr_size = sizeof arr)
+///
+/// Allocate new unmanaged array. Delete with "MEM_UM_delete"
+///
+/// AMX
+/// Params
+/// Pointer of allocated memory if successful, otherwise "MEM_NULLUMPTR"
+/// UnmanagedPointer:MEM_UM_new_arr(const arr[], arr_size = sizeof arr)
cell AMX_NATIVE_CALL AMX_MEM_UM_new_arr(AMX *amx, cell *params)
{
cell *ret(nullptr);
@@ -475,7 +605,13 @@ cell AMX_NATIVE_CALL AMX_MEM_UM_new_arr(AMX *amx, cell *params)
return reinterpret_cast(ret);
}
-// UnmanagedPointer:MEM_UM_clone(AnyPointer:pointer, index = 0, cells)
+///
+/// Clone unmanaged memory. Delete with "MEM_UM_delete"
+///
+/// AMX
+/// Params
+/// Pointer of allocated memory if successful, otherwise "MEM_NULLUMPTR"
+/// UnmanagedPointer:MEM_UM_clone(AnyPointer:pointer, index = 0, cells)
cell AMX_NATIVE_CALL AMX_MEM_UM_clone(AMX *amx, cell *params)
{
cell *ret(nullptr);
@@ -524,7 +660,13 @@ cell AMX_NATIVE_CALL AMX_MEM_UM_clone(AMX *amx, cell *params)
return reinterpret_cast(ret);
}
-// MEM_UM_delete(UnmanagedPointer:pointer)
+///
+/// Delete unmanaged memory
+///
+/// AMX
+/// Params
+/// Nothing
+/// MEM_UM_delete(UnmanagedPointer:pointer)
cell AMX_NATIVE_CALL AMX_MEM_UM_delete(AMX *amx, cell *params)
{
if (NumArgsEqual(params, 1, "MEM_UM_delete"))
@@ -535,7 +677,13 @@ cell AMX_NATIVE_CALL AMX_MEM_UM_delete(AMX *amx, cell *params)
return 0;
}
-// MEM_UM_get_val(AnyPointer:pointer, index = 0)
+///
+/// Get value from unmanaged memory
+///
+/// AMX
+/// Params
+/// Value if successful, otherwise "0"
+/// MEM_UM_get_val(AnyPointer:pointer, index = 0)
cell AMX_NATIVE_CALL AMX_MEM_UM_get_val(AMX *amx, cell *params)
{
cell ret(0);
@@ -562,7 +710,13 @@ cell AMX_NATIVE_CALL AMX_MEM_UM_get_val(AMX *amx, cell *params)
return ret;
}
-// UnmanagedPointer:MEM_UM_get_arr(AnyPointer:pointer, index = 0, arr[], arr_size = sizeof arr)
+///
+/// Get array from unmanaged memory
+///
+/// AMX
+/// Params
+/// Pointer of array if successful, otherwise "MEM_NULLFEPTR"
+/// UnmanagedPointer:MEM_UM_get_arr(AnyPointer:pointer, index = 0, arr[], arr_size = sizeof arr)
cell AMX_NATIVE_CALL AMX_MEM_UM_get_arr(AMX *amx, cell *params)
{
cell *ret(nullptr);
@@ -597,7 +751,13 @@ cell AMX_NATIVE_CALL AMX_MEM_UM_get_arr(AMX *amx, cell *params)
return reinterpret_cast(ret);
}
-// MEM_UM_set_val(UnmanagedPointer:pointer, index = 0, value)
+///
+/// Set value at unmanaged memory
+///
+/// AMX
+/// Params
+/// Value if successful, otherwise "0"
+/// MEM_UM_set_val(UnmanagedPointer:pointer, index = 0, value)
cell AMX_NATIVE_CALL AMX_MEM_UM_set_val(AMX *amx, cell *params)
{
cell ret(0);
@@ -624,7 +784,13 @@ cell AMX_NATIVE_CALL AMX_MEM_UM_set_val(AMX *amx, cell *params)
return ret;
}
-// ForeignPointer:MEM_UM_set_arr(UnmanagedPointer:pointer, index = 0, const arr[], arr_size = sizeof arr)
+///
+/// Set array at unmanaged memory
+///
+/// AMX
+/// Params
+/// Pointer of array if successful, otherwise "MEM_NULLFEPTR"
+/// ForeignPointer:MEM_UM_set_arr(UnmanagedPointer:pointer, index = 0, const arr[], arr_size = sizeof arr)
cell AMX_NATIVE_CALL AMX_MEM_UM_set_arr(AMX *amx, cell *params)
{
cell *ret(nullptr);
@@ -659,7 +825,13 @@ cell AMX_NATIVE_CALL AMX_MEM_UM_set_arr(AMX *amx, cell *params)
return reinterpret_cast(ret);
}
-// UnmanagedPointer:MEM_UM_copy(UnmanagedPointer:dest, AnyPointer:src, size, dest_index = 0, src_index = 0)
+///
+/// Copy unmanaged memory
+///
+/// AMX
+/// Params
+/// Pointer of destination if successful, otherwise "MEM_NULLUMPTR"
+/// UnmanagedPointer:MEM_UM_copy(UnmanagedPointer:dest, AnyPointer:src, size, dest_index = 0, src_index = 0)
cell AMX_NATIVE_CALL AMX_MEM_UM_copy(AMX *amx, cell *params)
{
cell *ret(nullptr);
@@ -692,7 +864,13 @@ cell AMX_NATIVE_CALL AMX_MEM_UM_copy(AMX *amx, cell *params)
return reinterpret_cast(ret);
}
-// UnmanagedPointer:MEM_UM_zero(UnmanagedPointer:pointer, size, index = 0)
+///
+/// Zero unmanaged memory
+///
+/// AMX
+/// Params
+/// Pointer of destination if successful, otherwise "MEM_NULLUMPTR"
+/// UnmanagedPointer:MEM_UM_zero(UnmanagedPointer:pointer, size, index = 0)
cell AMX_NATIVE_CALL AMX_MEM_UM_zero(AMX *amx, cell *params)
{
cell *ret(nullptr);
@@ -725,7 +903,13 @@ cell AMX_NATIVE_CALL AMX_MEM_UM_zero(AMX *amx, cell *params)
return reinterpret_cast(ret);
}
-// ForeignPointer:MEM_UM_get_addr(&var)
+///
+/// Get pointer of variable
+///
+/// AMX
+/// Params
+/// Pointer of variable if successful, otherwise "MEM_NULLFEPTR"
+/// ForeignPointer:MEM_UM_get_addr(&var)
cell AMX_NATIVE_CALL AMX_MEM_UM_get_addr(AMX *amx, cell *params)
{
cell *ret(nullptr);
@@ -737,20 +921,33 @@ cell AMX_NATIVE_CALL AMX_MEM_UM_get_addr(AMX *amx, cell *params)
return reinterpret_cast(ret);
}
-// ForeignPointer:MEM_UM_get_amx_ptr()
+///
+/// Get AMX pointer
+///
+/// AMX
+/// Params
+/// AMX pointer
+/// ForeignPointer:MEM_UM_get_amx_ptr()
cell AMX_NATIVE_CALL AMX_MEM_UM_get_amx_ptr(AMX *amx, cell *params)
{
lastResult = EMemoryResult_OK;
return reinterpret_cast(amx);
}
-// Supports
+///
+/// Plugin supports
+///
+/// Plugin supports flags
PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports()
{
return SUPPORTS_VERSION | SUPPORTS_AMX_NATIVES;
}
-// Load
+///
+/// Load plugin
+///
+/// Plugin data
+/// "true" if successful, otherwise "false"
PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData)
{
pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS];
@@ -763,7 +960,9 @@ PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData)
return true;
}
-// Unload
+///
+/// Plugin unload
+///
PLUGIN_EXPORT void PLUGIN_CALL Unload()
{
ManagedMemory::Clear();
@@ -774,7 +973,9 @@ PLUGIN_EXPORT void PLUGIN_CALL Unload()
logprintf("========================");
}
-// Plugin natives
+///
+/// Plugin natives
+///
AMX_NATIVE_INFO PluginNatives[] =
{
{ "MEM_new", AMX_MEM_new },
@@ -811,13 +1012,21 @@ AMX_NATIVE_INFO PluginNatives[] =
{0, 0}
};
-// AMX load
+///
+/// AMX load
+///
+/// AMX
+/// Return value of "amx_Register"
PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX *amx)
{
return amx_Register(amx, PluginNatives, -1);
}
-// AMX unload
+///
+/// AMX unload
+///
+/// AMX
+/// Error code
PLUGIN_EXPORT int PLUGIN_CALL AmxUnload(AMX *amx)
{
return AMX_ERR_NONE;
diff --git a/pawn-memory/pawn-memory.vcxproj b/pawn-memory/pawn-memory.vcxproj
index 23a9eb3..4e3e106 100644
--- a/pawn-memory/pawn-memory.vcxproj
+++ b/pawn-memory/pawn-memory.vcxproj
@@ -21,13 +21,13 @@
DynamicLibrary
true
- v141
+ v141_xp
Unicode
DynamicLibrary
false
- v141
+ v141_xp
true
Unicode
| | | | | | | | | | | | | | | | | | | | | | | | | | | | |