Leaked source code of windows server 2003
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.

35 lines
1009 B

  1. // util.h : Utility inlines/functions
  2. // Copyright (c)1999 Microsoft Corporation, All Rights Reserved
  3. // added during 64 bit port of triedit.
  4. // All throughout the triedit code, we assume that
  5. // the size of the document is not going to exceed
  6. // 2GB. We assert the fact when we open the document
  7. // in filter.cpp as well. If at later point, we do exceed
  8. // the document size of 2GB, we need to change this too.
  9. // Safe conversion of pointer differences.
  10. #ifndef __UTIL_H_
  11. #define __UTIL_H_
  12. inline WORD SAFE_PTR_DIFF_TO_WORD(SIZE_T lptrDiff)
  13. {
  14. _ASSERTE(lptrDiff <= USHRT_MAX);
  15. return((WORD)lptrDiff);
  16. };
  17. inline WORD SAFE_INT_DIFF_TO_WORD(int iDiff)
  18. {
  19. _ASSERTE(iDiff <= USHRT_MAX);
  20. return((WORD)iDiff);
  21. };
  22. inline int SAFE_PTR_DIFF_TO_INT(SIZE_T lptrDiff)
  23. {
  24. _ASSERTE(lptrDiff <= UINT_MAX);
  25. return((int)lptrDiff);
  26. };
  27. inline DWORD SAFE_INT64_TO_DWORD(SIZE_T iValue)
  28. {
  29. _ASSERTE(iValue <= UINT_MAX);
  30. return((DWORD)iValue);
  31. };
  32. #endif __UTIL_H_