ReactOS  0.4.13-dev-982-g9853eab
_stdexcept_base.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1996,1997
3  * Silicon Graphics Computer Systems, Inc.
4  *
5  * Copyright (c) 1999
6  * Boris Fomitchev
7  *
8  * This material is provided "as is", with absolutely no warranty expressed
9  * or implied. Any use is at your own risk.
10  *
11  * Permission to use or copy this software for any purpose is hereby granted
12  * without fee, provided the above notices are retained on all copies.
13  * Permission to modify the code and to distribute modified code is granted,
14  * provided the above notices are retained, and a notice that the code was
15  * modified is included with the above copyright notice.
16  *
17  */
18 
20  size_t __size = strlen(_STLP_PRIV __get_c_string(__str)) + 1;
21  if (__size > _S_bufsize) {
22  _M_name = __STATIC_CAST(char*, malloc(__size * sizeof(char)));
23  if (!_M_name) {
24  __size = _S_bufsize;
26  }
27  else {
28  *(__REINTERPRET_CAST(size_t*, &_M_static_name[0])) = __size * sizeof(char);
29  }
30  }
31  else {
33  }
34 #if !defined (_STLP_USE_SAFE_STRING_FUNCTIONS)
35  strncpy(_M_name, _STLP_PRIV __get_c_string(__str), __size - 1);
36  _M_name[__size - 1] = '\0';
37 #else
38  strncpy_s(_M_name, __size, _STLP_PRIV __get_c_string(__str), __size - 1);
39 #endif
40 }
41 
43  size_t __size = strlen(__x._M_name) + 1;
44  if (__size > _S_bufsize) {
45  _M_name = __STATIC_CAST(char*, malloc(__size * sizeof(char)));
46  if (!_M_name) {
47  __size = _S_bufsize;
49  }
50  else {
51  *(__REINTERPRET_CAST(size_t*, &_M_static_name[0])) = __size * sizeof(char);
52  }
53  }
54  else {
56  }
57 #if !defined (_STLP_USE_SAFE_STRING_FUNCTIONS)
58  strncpy(_M_name, __x._M_name, __size - 1);
59  _M_name[__size - 1] = '\0';
60 #else
61  strncpy_s(_M_name, __size, __x._M_name, __size - 1);
62 #endif
63 }
64 
66  size_t __size = strlen(__x._M_name) + 1;
67  size_t __buf_size = _M_name != _M_static_name ? *(__REINTERPRET_CAST(size_t*, &_M_static_name[0])) : _S_bufsize;
68  if (__size > __buf_size) {
69  // Being here necessarily mean that we need to allocate a buffer:
71  _M_name = __STATIC_CAST(char*, malloc(__size * sizeof(char)));
72  if (!_M_name) {
73  __size = _S_bufsize;
75  }
76  else {
77  *(__REINTERPRET_CAST(size_t*, &_M_static_name[0])) = __size * sizeof(char);
78  }
79  }
80 #if !defined (_STLP_USE_SAFE_STRING_FUNCTIONS)
81  strncpy(_M_name, __x._M_name, __size - 1);
82  _M_name[__size - 1] = '\0';
83 #else
84  strncpy_s(_M_name, __size, __x._M_name, __size - 1);
85 #endif
86  return *this;
87 }
88 
90  if (_M_name != _M_static_name)
91  free(_M_name);
92 }
93 
95 { return _M_name; }
const char * what() const _STLP_NOTHROW_INHERENTLY
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define free
Definition: debug_ros.c:5
const char *_STLP_CALL __get_c_string(const string &__str)
Definition: _string.h:1163
#define _STLP_NOTHROW_INHERENTLY
Definition: features.h:858
__Named_exception(const string &__str)
#define _STLP_PRIV
Definition: _dm.h:70
#define __REINTERPRET_CAST(__x, __y)
Definition: features.h:586
char _M_static_name[_S_bufsize]
int CDECL strncpy_s(char *dest, size_t numberOfElements, const char *src, size_t count)
Definition: heap.c:577
#define const
Definition: zconf.h:230
#define malloc
Definition: debug_ros.c:4
~__Named_exception() _STLP_NOTHROW_INHERENTLY
__Named_exception & operator=(const __Named_exception &)