⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _debug.c

📁 改进版本的c++类模版库和其原代码
💻 C
📖 第 1 页 / 共 2 页
字号:
	va_start( __args, __format_str );# if defined (_STLP_WINCE)	TCHAR __buffer[512];	int _convert = strlen(__format_str) + 1;	LPWSTR _lpw = (LPWSTR)alloca(_convert*sizeof(wchar_t));	_lpw[0] = '\0';	MultiByteToWideChar(GetACP(), 0, __format_str, -1, _lpw, _convert);	wvsprintf(__buffer, _lpw, __args);	//	wvsprintf(__buffer, __format_str, __args);	_STLP_WINCE_TRACE(__buffer);# elif defined (_STLP_WIN32) && ( defined(_STLP_MSVC) || defined (__ICL) || defined (__BORLANDC__))    char __buffer [4096];    _vsnprintf(__buffer, sizeof(__buffer) / sizeof(char),               __format_str, __args);    OutputDebugStringA(__buffer);# elif defined (__amigaos__)    STLPORT_CSTD::vfprintf(stderr, __format_str, (char *)__args);# else    STLPORT_CSTD::vfprintf(stderr, __format_str, __args);# endif /* WINCE */# ifdef _STLP_DEBUG_MESSAGE_POST	_STLP_DEBUG_MESSAGE_POST# endif    va_end(__args);}_STLP_END_NAMESPACE#  endif /* _STLP_DEBUG_MESSAGE */_STLP_BEGIN_NAMESPACEtemplate <class _Dummy>void _STLP_CALL  __stl_debug_engine<_Dummy>::_IndexedError(int __error_ind, const char* __f, int __l){  __stl_debug_message(_Message_table[_StlFormat_ERROR_RETURN], 		      __f, __l, _Message_table[__error_ind]);}template <class _Dummy>void _STLP_CALL  __stl_debug_engine<_Dummy>::_VerboseAssert(const char* __expr, int __error_ind, const char* __f, int __l){  __stl_debug_message(_Message_table[_StlFormat_VERBOSE_ASSERTION_FAILURE],		      __f, __l, _Message_table[__error_ind], __f, __l, __expr);  __stl_debug_terminate();}template <class _Dummy>void _STLP_CALL __stl_debug_engine<_Dummy>::_Assert(const char* __expr, const char* __f, int __l){  __stl_debug_message(_Message_table[_StlFormat_ASSERTION_FAILURE],__f, __l, __expr);  __stl_debug_terminate();}// if exceptions are present, sends unique exception// if not, calls abort() to terminatetemplate <class _Dummy>void _STLP_CALL __stl_debug_engine<_Dummy>::_Terminate(){# ifdef _STLP_USE_NAMESPACES  using namespace _STLP_STD;# endif# if defined (_STLP_USE_EXCEPTIONS) && ! defined (_STLP_NO_DEBUG_EXCEPTIONS)  throw __stl_debug_exception();# else  _STLP_ABORT();# endif}_STLP_END_NAMESPACE# endif /* _STLP_ASSERTIONS */#ifdef _STLP_DEBUG_STLP_BEGIN_NAMESPACE//==========================================================//  owned_list non-inline methods //==========================================================template <class _Dummy>void  _STLP_CALL__stl_debug_engine<_Dummy>::_Invalidate_all(__owned_list* __l) {  _STLP_ACQUIRE_LOCK(__l->_M_lock);  _Stamp_all(__l, 0);  __l->_M_node._M_next =0;  _STLP_RELEASE_LOCK(__l->_M_lock);}// boris : this is unasafe routine; should be used from within critical section only !template <class _Dummy>void  _STLP_CALL__stl_debug_engine<_Dummy>::_Stamp_all(__owned_list* __l, __owned_list* __o) {  // crucial  if (__l->_M_node._M_owner) {    for (__owned_link*  __position = (__owned_link*)__l->_M_node._M_next; 	 __position != 0; __position= (__owned_link*)__position->_M_next) {      _STLP_ASSERT(__position->_Owner()== __l)      __position->_M_owner=__o;    }  }}template <class _Dummy>void  _STLP_CALL__stl_debug_engine<_Dummy>::_Verify(const __owned_list* __l) {  _STLP_ACQUIRE_LOCK(__l->_M_lock);  if (__l) {    _STLP_ASSERT(__l->_M_node._Owner() != 0)    for (__owned_link* __position = (__owned_link*)__l->_M_node._M_next;          __position != 0; __position= (__owned_link*)__position->_M_next) {      _STLP_ASSERT(__position->_Owner()== __l)    }  }  _STLP_RELEASE_LOCK(__l->_M_lock);}template <class _Dummy>void _STLP_CALL  __stl_debug_engine<_Dummy>::_Swap_owners(__owned_list& __x, __owned_list& __y) {  //  according to the standard : --no swap() function invalidates any references,   //  pointers,  or  iterators referring to the elements of the containers being swapped.  __owned_link* __tmp;  // boris : there is a deadlock potential situation here if we lock two containers sequentially.  // As user is supposed to provide its own synchronization around swap() ( it is unsafe to do any container/iterator access  // in parallel with swap()), we just do not use any locking at all -- that behaviour is closer to non-debug version  __tmp = __x._M_node._M_next;  _Stamp_all(&__x, &__y);  _Stamp_all(&__y, &__x);  __x._M_node._M_next = __y._M_node._M_next;  __y._M_node._M_next = __tmp;  }template <class _Dummy>void _STLP_CALL __stl_debug_engine<_Dummy>::_M_detach(__owned_list* __l, __owned_link* __c_node) {  if (__l  != 0) {    _STLP_VERBOSE_ASSERT(__l->_Owner()!=0, _StlMsg_INVALID_CONTAINER)    _STLP_ACQUIRE_LOCK(__l->_M_lock)      // boris : re-test the condition in case someone else already deleted us      if(__c_node->_M_owner != 0) {        __owned_link* __prev, *__next;                for (__prev = &__l->_M_node; (__next = __prev->_M_next) != __c_node;              __prev = __next) {          _STLP_ASSERT(__next && __next->_Owner() == __l)            }                __prev->_M_next = __c_node->_M_next;        __c_node->_M_owner=0;      }    _STLP_RELEASE_LOCK(__l->_M_lock)  }}template <class _Dummy>void _STLP_CALL __stl_debug_engine<_Dummy>::_M_attach(__owned_list* __l, __owned_link* __c_node) {  if (__l ==0) {    (__c_node)->_M_owner = 0;      } else {    _STLP_VERBOSE_ASSERT(__l->_Owner()!=0, _StlMsg_INVALID_CONTAINER)    _STLP_ACQUIRE_LOCK(__l->_M_lock)    __c_node->_M_owner = __l;    __c_node->_M_next = __l->_M_node._M_next;    __l->_M_node._M_next = __c_node;    _STLP_RELEASE_LOCK(__l->_M_lock)  }}template <class _Dummy>void* _STLP_CALL__stl_debug_engine<_Dummy>::_Get_container_ptr(const __owned_link* __l) {  const __owned_list* __owner    = __l->_Owner();  _STLP_VERBOSE_RETURN_0(__owner != 0, _StlMsg_INVALID_ITERATOR)  void* __ret = __CONST_CAST(void*,__owner->_Owner());  _STLP_VERBOSE_RETURN_0(__ret !=0, _StlMsg_INVALID_CONTAINER)  return __ret;}template <class _Dummy>bool _STLP_CALL__stl_debug_engine<_Dummy>::_Check_same_owner( const __owned_link& __i1,                                                const __owned_link& __i2){  _STLP_VERBOSE_RETURN(__i1._Valid(), _StlMsg_INVALID_LEFTHAND_ITERATOR)  _STLP_VERBOSE_RETURN(__i2._Valid(), _StlMsg_INVALID_RIGHTHAND_ITERATOR)  _STLP_VERBOSE_RETURN((__i1._Owner()==__i2._Owner()), _StlMsg_DIFFERENT_OWNERS)  return true;}template <class _Dummy>bool  _STLP_CALL__stl_debug_engine<_Dummy>::_Check_same_owner_or_null( const __owned_link& __i1, 						       const __owned_link& __i2){  _STLP_VERBOSE_RETURN(__i1._Owner()==__i2._Owner(), _StlMsg_DIFFERENT_OWNERS)  return true;}template <class _Dummy>bool _STLP_CALL__stl_debug_engine<_Dummy>::_Check_if_owner( const __owned_list * __l, const __owned_link& __it){  const __owned_list* __owner_ptr = __it._Owner();  _STLP_VERBOSE_RETURN(__owner_ptr!=0, _StlMsg_INVALID_ITERATOR)  _STLP_VERBOSE_RETURN(__l==__owner_ptr, _StlMsg_NOT_OWNER)  return true;}_STLP_END_NAMESPACE#endif /* _STLP_DEBUG */#endif /* if defined (EXPOSE_GLOBALS_IMPLEMENTATION) */#endif /* header guard */// Local Variables:// mode:C++// End:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -