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

/***
*typename.cpp - Implementation of type_info.name() for RTTI.
*
* Copyright (c) 1995-2001, Microsoft Corporation. All rights reserved.
*
*Purpose:
* This module provides an implementation of the class member function
* type_info.name() for Run-Time Type Information (RTTI).
*
*Revision History:
* 06-19-95 JWM broken out from typeinfo.cpp for granularity.
* 07-02-95 JWM now locks around assignment to _m_data.
* 12-18-95 JWM debug type_info::name() now calls _malloc_crt().
* 09-07-00 PML Get rid of /lib:libcp directive in obj (vs7#159463)
* 02-19-01 GB Added Check for return value of malloc
* 07-15-01 PML Remove all ALPHA, MIPS, and PPC code
*
****/
#define _USE_ANSI_CPP /* Don't emit /lib:libcp directive */
#include <stdlib.h>
#include <typeinfo.h>
#include <mtdll.h>
#include <string.h>
#include <dbgint.h>
#include <undname.h>
_CRTIMP const char* type_info::name() const //17.3.4.2.5
{
void *pTmpUndName;
if (this->_m_data == NULL) {
#ifdef _DEBUG /* CRT debug lib build */
if ((pTmpUndName = __unDName(NULL, (this->_m_d_name)+1, 0, &_malloc_base, &_free_base, UNDNAME_32_BIT_DECODE | UNDNAME_TYPE_ONLY)) == NULL)
return NULL;
#else
if ((pTmpUndName = __unDName(NULL, (this->_m_d_name)+1, 0, &malloc, &free, UNDNAME_32_BIT_DECODE | UNDNAME_TYPE_ONLY)) == NULL)
return NULL;
#endif
for (int l=(int)strlen((char *)pTmpUndName)-1; ((char *)pTmpUndName)[l] == ' '; l--)
((char *)pTmpUndName)[l] = '\0';
_mlock (_TYPEINFO_LOCK);
#ifdef _DEBUG /* CRT debug lib build */
if ((((type_info *)this)->_m_data = _malloc_crt (strlen((char *)pTmpUndName) + 1)) != NULL)
strcpy ((char *)((type_info *)this)->_m_data, (char *)pTmpUndName);
_free_base (pTmpUndName);
#else
if ((((type_info *)this)->_m_data = malloc (strlen((char *)pTmpUndName) + 1)) != NULL)
strcpy ((char *)((type_info *)this)->_m_data, (char *)pTmpUndName);
free (pTmpUndName);
#endif
_munlock(_TYPEINFO_LOCK);
}
return (char *) this->_m_data;
}