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.

62 lines
2.2 KiB

  1. /***
  2. *typename.cpp - Implementation of type_info.name() for RTTI.
  3. *
  4. * Copyright (c) 1995-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * This module provides an implementation of the class member function
  8. * type_info.name() for Run-Time Type Information (RTTI).
  9. *
  10. *Revision History:
  11. * 06-19-95 JWM broken out from typeinfo.cpp for granularity.
  12. * 07-02-95 JWM now locks around assignment to _m_data.
  13. * 12-18-95 JWM debug type_info::name() now calls _malloc_crt().
  14. * 09-07-00 PML Get rid of /lib:libcp directive in obj (vs7#159463)
  15. * 02-19-01 GB Added Check for return value of malloc
  16. * 07-15-01 PML Remove all ALPHA, MIPS, and PPC code
  17. *
  18. ****/
  19. #define _USE_ANSI_CPP /* Don't emit /lib:libcp directive */
  20. #include <stdlib.h>
  21. #include <typeinfo.h>
  22. #include <mtdll.h>
  23. #include <string.h>
  24. #include <dbgint.h>
  25. #include <undname.h>
  26. _CRTIMP const char* type_info::name() const //17.3.4.2.5
  27. {
  28. void *pTmpUndName;
  29. if (this->_m_data == NULL) {
  30. #ifdef _DEBUG /* CRT debug lib build */
  31. if ((pTmpUndName = __unDName(NULL, (this->_m_d_name)+1, 0, &_malloc_base, &_free_base, UNDNAME_32_BIT_DECODE | UNDNAME_TYPE_ONLY)) == NULL)
  32. return NULL;
  33. #else
  34. if ((pTmpUndName = __unDName(NULL, (this->_m_d_name)+1, 0, &malloc, &free, UNDNAME_32_BIT_DECODE | UNDNAME_TYPE_ONLY)) == NULL)
  35. return NULL;
  36. #endif
  37. for (int l=(int)strlen((char *)pTmpUndName)-1; ((char *)pTmpUndName)[l] == ' '; l--)
  38. ((char *)pTmpUndName)[l] = '\0';
  39. _mlock (_TYPEINFO_LOCK);
  40. #ifdef _DEBUG /* CRT debug lib build */
  41. if ((((type_info *)this)->_m_data = _malloc_crt (strlen((char *)pTmpUndName) + 1)) != NULL)
  42. strcpy ((char *)((type_info *)this)->_m_data, (char *)pTmpUndName);
  43. _free_base (pTmpUndName);
  44. #else
  45. if ((((type_info *)this)->_m_data = malloc (strlen((char *)pTmpUndName) + 1)) != NULL)
  46. strcpy ((char *)((type_info *)this)->_m_data, (char *)pTmpUndName);
  47. free (pTmpUndName);
  48. #endif
  49. _munlock(_TYPEINFO_LOCK);
  50. }
  51. return (char *) this->_m_data;
  52. }