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.

44 lines
836 B

  1. #undef SAFEDELETE
  2. #define SAFEDELETE(p) if ((p) != NULL) { delete (p); (p) = NULL; };
  3. #undef SAFEDELETEARRAY
  4. #define SAFEDELETEARRAY(p) if ((p) != NULL) { delete[] (p); (p) = NULL; };
  5. #undef SAFERELEASE
  6. #define SAFERELEASE(p) if ((p) != NULL) { (p)->Release(); (p) = NULL; };
  7. inline
  8. WCHAR*
  9. WSTRDupDynamic(LPCWSTR pwszSrc)
  10. {
  11. LPWSTR pwszDest = NULL;
  12. if (pwszSrc != NULL)
  13. {
  14. const DWORD dwLen = lstrlenW(pwszSrc) + 1;
  15. pwszDest = new WCHAR[dwLen];
  16. if( pwszDest )
  17. memcpy(pwszDest, pwszSrc, dwLen * sizeof(WCHAR));
  18. }
  19. return pwszDest;
  20. }
  21. inline
  22. LPBYTE
  23. MemDupDynamic(const BYTE *pSrc, DWORD cb)
  24. {
  25. LPBYTE pDest = NULL;
  26. pDest = new BYTE[cb];
  27. if(pDest)
  28. memcpy(pDest, pSrc, cb);
  29. return pDest;
  30. }
  31. HRESULT
  32. RemoveDirectoryAndChildren(LPWSTR szDir);