You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.1 KiB

  1. #pragma once
  2. #pragma warning( disable : 4028 28251 6001 )
  3. #include <debugapi.h>
  4. HANDLE hHeap;
  5. #define memalloc(size) HeapAlloc(hHeap, HEAP_GENERATE_EXCEPTIONS, size)
  6. #define memcalloc(size) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, size)
  7. #define memfree(mem) HeapFree(hHeap, 0, mem)
  8. #define STR_LEN(str) (sizeof(str) / sizeof(str[0]))
  9. #define DEBUG_BREAK { if (IsDebuggerPresent()) { __debugbreak(); } }
  10. inline void *wmemcpy(wchar_t *dst, const wchar_t *src, size_t n)
  11. {
  12. wchar_t *d = dst;
  13. const wchar_t *s = src;
  14. while (n--)
  15. *d++ = *s++;
  16. return dst;
  17. }
  18. inline void *wmemset(wchar_t *dst, wchar_t c, size_t n)
  19. {
  20. wchar_t *d = dst;
  21. while (n--)
  22. *(d++) = c;
  23. return dst;
  24. }
  25. void *memset(void *dst, char c, int n)
  26. {
  27. char *d = dst;
  28. while (n--)
  29. *d = c;
  30. return dst;
  31. }
  32. inline void *memcpy(void *dst, const void *src, int n)
  33. {
  34. char *d = dst;
  35. const char *s = src;
  36. while (n--)
  37. *d++ = *s++;
  38. return dst;
  39. }
  40. inline size_t wcslen(wchar_t const *str)
  41. {
  42. size_t result = 0;
  43. while (*str++)
  44. result++;
  45. return result;
  46. }
  47. inline size_t strlen(char const *str)
  48. {
  49. size_t result = 0;
  50. while (*str++)
  51. result++;
  52. return result;
  53. }