SHARE
TWEET

memory.inc

BigETI Jul 11th, 2013 (edited) 802 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #if defined _MEMORY_INCLUDED_
  2.         #endinput
  3. #endif
  4. #define _MEMORY_INCLUDED_
  5. #if defined MEM_NULL_EX
  6.         #define MEM_MACR_NULL                           (0)
  7. #else
  8.         #if !defined NULL
  9.                 #define NULL                                    (0)
  10.         #endif
  11. #endif
  12. #define MEM_struct                                              enum _:
  13. #define MEM_MACR_SIZEOF_CELL                    (4)
  14. #define MEM_MACR_get_addr%2(%0->%1)             (MEM_get_addr(%0)+Pointer:((%1)*MEM_MACR_SIZEOF_CELL))
  15. #define MEM_MACR_get_val%2(%0->%1)              MEM_get_val(%0,%1)
  16. #define MEM_MACR_get_ptr%2(%0->%1)              (%0+Pointer:((%1)*MEM_MACR_SIZEOF_CELL))
  17. #define MEM_MACR_foreach%2(%0,%1)               for(new %1=0;(%1)<(%0);%1++)
  18. #define MEM_MACR_foreach_rev%2(%0,%1)   for(new %1=((%0)-MEM_MACR_SIZEOF_CELL);(%1)>=0;%1--)
  19. #define MEM_MACR_increment_ptr%1(%0)    (%0+=MEM_MACR_SIZEOF_CELL)
  20. #define MEM_MACR_decrement_ptr%1(%0)    (%0-=MEM_MACR_SIZEOF_CELL)
  21. enum MEM_E_sort_type
  22. {
  23.         MEM_E_sort_default,
  24.         MEM_E_sort_reverse
  25. }
  26. native Pointer:MEM_malloc(cells = 1);
  27. native Pointer:MEM_calloc(cells = 1);
  28. native Pointer:MEM_realloc(Pointer:pointer, cells = 1);
  29. native MEM_free(Pointer:pointer);
  30. native MEM_get_val(Pointer:pointer, index = 0);
  31. native Pointer:MEM_get_arr(Pointer:pointer, index = 0, arr[], arr_size = sizeof arr);
  32. native MEM_set_val(Pointer:pointer, index = 0, value);
  33. native Pointer:MEM_set_arr(Pointer:pointer, index = 0, const data_arr[], arr_size = sizeof data_arr);
  34. native Pointer:MEM_copy(Pointer:dest, Pointer:src, len, dest_index = 0, src_index = 0);
  35. //native MEM_compare(Pointer:lhs, Pointer:rhs, size, lhs_offset = 0, rhs_offset = 0);
  36. native Pointer:MEM_zero(Pointer:pointer, size, index = 0);
  37. native Pointer:MEM_get_addr(&var);
  38. native bool:MEM_sort(Pointer:pointer, index = 0, cells = 2, MEM_E_sort_type:sort = MEM_E_sort_default);
  39. native bool:MEM_mix(Pointer:pointer, index = 0, cells = 2, mix_times = 5);
  40. native Pointer:MEM_amx_ptr();
  41. #if defined SECURE_MEMORY_PLUGIN
  42. enum MEM_E_res
  43. {
  44.         MEM_E_res_ok,
  45.         MEM_E_res_no_alloc,
  46.         MEM_E_res_inv_ptr,
  47.         MEM_E_res_neg_index,
  48.         MEM_E_res_inv_index,
  49.         MEM_E_res_null_arr,
  50.         MEM_E_res_inv_size,
  51.         MEM_E_res_inv_op
  52. }
  53. native bool:MEM_is(Pointer:pointer, index = 0);
  54. native MEM_len(Pointer:pointer);
  55. native MEM_E_res:MEM_result(bool:free_result = true);
  56. #endif
  57. #define MEM::                                                   MEM_
  58. #define MEMORY::                                                MEM_
  59. #define MEM_EX::                                                MEM_MACR_
  60. #define MEMORY_EX::                                             MEM_MACR_
  61. #define MEM_MACR::                                              MEM_MACR_
  62. #define MEMORY_MACRO::                                  MEM_MACR_
  63. #define MEM_E::                                                 MEM_E_
  64. #define MEM_ENUM::                                              MEM_E_
  65. #define MEMORY_ENUM::                                   MEM_E_
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top