Source code of Windows XP (NT5)
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.

87 lines
1.5 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. svsutil.cxx
  5. Abstract:
  6. Miscellaneous useful utilities
  7. Author:
  8. Sergey Solyanik (SergeyS)
  9. --*/
  10. #include "pch.h"
  11. #pragma hdrstop
  12. #include <svsutil.hxx>
  13. //
  14. // Assert and debug sector
  15. //
  16. static int svsutil_DebugOut (void *pvPtr, TCHAR *lpszFormat, ...) {
  17. va_list lArgs;
  18. va_start (lArgs, lpszFormat);
  19. #if defined (UNDER_CE)
  20. TCHAR szBuffer[128];
  21. int iRet = wvsprintf (szBuffer, lpszFormat, lArgs);
  22. OutputDebugString (szBuffer);
  23. #else
  24. int iRet = vwprintf (lpszFormat, lArgs);
  25. #endif
  26. va_end(lArgs);
  27. return iRet;
  28. }
  29. FuncDebugOut g_funcDebugOut = svsutil_DebugOut;
  30. void *g_pvDebugData = NULL;
  31. int svsutil_AssertBroken (TCHAR *lpszFileName, int iLine) {
  32. g_funcDebugOut (g_pvDebugData, TEXT("Assert broken in %s line %d\n"), lpszFileName, iLine);
  33. DebugBreak ();
  34. return TRUE;
  35. }
  36. wchar_t *svsutil_wcsdup (wchar_t *lpwszString) {
  37. int iSz = (wcslen (lpwszString) + 1) * sizeof(wchar_t);
  38. wchar_t *lpwszDup = (wchar_t *)g_funcAlloc (iSz, g_pvAllocData);
  39. if (! lpwszDup)
  40. {
  41. SVSUTIL_ASSERT (0);
  42. return NULL;
  43. }
  44. memcpy (lpwszDup, lpwszString, iSz);
  45. return lpwszDup;
  46. }
  47. char *svsutil_strdup (char *lpszString) {
  48. int iSz = strlen (lpszString) + 1;
  49. char *lpszDup = (char *)g_funcAlloc (iSz, g_pvAllocData);
  50. if (! lpszDup)
  51. {
  52. SVSUTIL_ASSERT (0);
  53. return NULL;
  54. }
  55. memcpy (lpszDup, lpszString, iSz);
  56. return lpszDup;
  57. }