Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygen_stdexcept_base.c
Go to the documentation of this file.
00001 /* 00002 * Copyright (c) 1996,1997 00003 * Silicon Graphics Computer Systems, Inc. 00004 * 00005 * Copyright (c) 1999 00006 * Boris Fomitchev 00007 * 00008 * This material is provided "as is", with absolutely no warranty expressed 00009 * or implied. Any use is at your own risk. 00010 * 00011 * Permission to use or copy this software for any purpose is hereby granted 00012 * without fee, provided the above notices are retained on all copies. 00013 * Permission to modify the code and to distribute modified code is granted, 00014 * provided the above notices are retained, and a notice that the code was 00015 * modified is included with the above copyright notice. 00016 * 00017 */ 00018 00019 __Named_exception::__Named_exception(const string& __str) { 00020 size_t __size = strlen(_STLP_PRIV __get_c_string(__str)) + 1; 00021 if (__size > _S_bufsize) { 00022 _M_name = __STATIC_CAST(char*, malloc(__size * sizeof(char))); 00023 if (!_M_name) { 00024 __size = _S_bufsize; 00025 _M_name = _M_static_name; 00026 } 00027 else { 00028 *(__REINTERPRET_CAST(size_t*, &_M_static_name[0])) = __size * sizeof(char); 00029 } 00030 } 00031 else { 00032 _M_name = _M_static_name; 00033 } 00034 #if !defined (_STLP_USE_SAFE_STRING_FUNCTIONS) 00035 strncpy(_M_name, _STLP_PRIV __get_c_string(__str), __size - 1); 00036 _M_name[__size - 1] = '\0'; 00037 #else 00038 strncpy_s(_M_name, __size, _STLP_PRIV __get_c_string(__str), __size - 1); 00039 #endif 00040 } 00041 00042 __Named_exception::__Named_exception(const __Named_exception& __x) { 00043 size_t __size = strlen(__x._M_name) + 1; 00044 if (__size > _S_bufsize) { 00045 _M_name = __STATIC_CAST(char*, malloc(__size * sizeof(char))); 00046 if (!_M_name) { 00047 __size = _S_bufsize; 00048 _M_name = _M_static_name; 00049 } 00050 else { 00051 *(__REINTERPRET_CAST(size_t*, &_M_static_name[0])) = __size * sizeof(char); 00052 } 00053 } 00054 else { 00055 _M_name = _M_static_name; 00056 } 00057 #if !defined (_STLP_USE_SAFE_STRING_FUNCTIONS) 00058 strncpy(_M_name, __x._M_name, __size - 1); 00059 _M_name[__size - 1] = '\0'; 00060 #else 00061 strncpy_s(_M_name, __size, __x._M_name, __size - 1); 00062 #endif 00063 } 00064 00065 __Named_exception& __Named_exception::operator = (const __Named_exception& __x) { 00066 size_t __size = strlen(__x._M_name) + 1; 00067 size_t __buf_size = _M_name != _M_static_name ? *(__REINTERPRET_CAST(size_t*, &_M_static_name[0])) : _S_bufsize; 00068 if (__size > __buf_size) { 00069 // Being here necessarily mean that we need to allocate a buffer: 00070 if (_M_name != _M_static_name) free(_M_name); 00071 _M_name = __STATIC_CAST(char*, malloc(__size * sizeof(char))); 00072 if (!_M_name) { 00073 __size = _S_bufsize; 00074 _M_name = _M_static_name; 00075 } 00076 else { 00077 *(__REINTERPRET_CAST(size_t*, &_M_static_name[0])) = __size * sizeof(char); 00078 } 00079 } 00080 #if !defined (_STLP_USE_SAFE_STRING_FUNCTIONS) 00081 strncpy(_M_name, __x._M_name, __size - 1); 00082 _M_name[__size - 1] = '\0'; 00083 #else 00084 strncpy_s(_M_name, __size, __x._M_name, __size - 1); 00085 #endif 00086 return *this; 00087 } 00088 00089 __Named_exception::~__Named_exception() _STLP_NOTHROW_INHERENTLY { 00090 if (_M_name != _M_static_name) 00091 free(_M_name); 00092 } 00093 00094 const char* __Named_exception::what() const _STLP_NOTHROW_INHERENTLY 00095 { return _M_name; } Generated on Fri May 25 2012 04:28:04 for ReactOS by
1.7.6.1
|