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.

40 lines
1.1 KiB

  1. /***
  2. * ostrptr.cpp - definitions for ostream operator<<(const void*) member function
  3. *
  4. * Copyright (c) 1991-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Member function definition for ostream operator<<(const void*).
  8. *
  9. *Revision History:
  10. * 09-23-91 KRS Created. Split out from ostream.cxx for granularity.
  11. * 06-03-92 KRS CAV #1183: add 'const' to ptr output argument.
  12. * 06-14-95 CFW Comment cleanup.
  13. * 04-04-02 PML Fix buffer overrun on Win64 (vswhidbey#2505)
  14. *
  15. *******************************************************************************/
  16. #include <cruntime.h>
  17. #include <internal.h>
  18. #include <stdio.h>
  19. #include <iostream.h>
  20. #pragma hdrstop
  21. ostream& ostream::operator<<(const void * ptr)
  22. {
  23. _WINSTATIC char obuffer[sizeof(void *) * 2 + 4];
  24. _WINSTATIC char fmt[4] = "%p";
  25. _WINSTATIC char leader[4] = "0x";
  26. if (opfx())
  27. {
  28. if (ptr)
  29. {
  30. if (x_flags & uppercase)
  31. leader[1] = 'X';
  32. }
  33. sprintf(obuffer,fmt,ptr);
  34. writepad(leader,obuffer);
  35. osfx();
  36. }
  37. return *this;
  38. }