@@ -36,7 +36,6 @@ char* String::strdup(const char* s)
36
36
String::String ()
37
37
: p( strdup(" " ) )
38
38
{
39
- _return_value = ' \0 ' ;
40
39
}
41
40
42
41
String::~String ()
@@ -55,13 +54,11 @@ String::String(const String& s)
55
54
size_ = s.size_ ;
56
55
memcpy (p, s.p , size_ + 1 );
57
56
}
58
- _return_value = ' \0 ' ;
59
57
}
60
58
61
59
String::String (const char * s)
62
60
: p(strdup(s))
63
61
{
64
- _return_value = ' \0 ' ;
65
62
}
66
63
67
64
String& String::operator =(const char * s)
@@ -179,16 +176,6 @@ String String::substr(const size_type pos, size_type length) const
179
176
180
177
181
178
// checked access, accessing the NUL at end is allowed
182
- char & String::at (const size_type i)
183
- {
184
- if ( i <= strlen (p) ) {
185
- _return_value = p[i];
186
- } else {
187
- _return_value = ' \0 ' ;
188
- }
189
- return _return_value;
190
- }
191
-
192
179
char String::at (const size_type i) const
193
180
{
194
181
if ( i <= strlen (p) ) {
@@ -236,6 +223,26 @@ String& String::append( const char* str, size_type n) {
236
223
return *this ;
237
224
}
238
225
226
+ String& String::append_raw ( const char * str, size_type n) {
227
+ if (str && n > 0 ) {
228
+ size_t newlen = size_ + n;
229
+ this ->reserve ( newlen );
230
+ memmove (p+size_, str, n); // p and s.p MAY overlap
231
+ p[newlen] = 0 ; // add NUL termination
232
+ size_ = newlen;
233
+ }
234
+ return *this ;
235
+ }
236
+
237
+ void String::append_int (int param) {
238
+
239
+ // max len of "-9223372036854775808" plus zero termination
240
+ char conv_buff[20 +1 ];
241
+
242
+ int len = itoa_c (param, conv_buff);
243
+ append_raw (conv_buff, len);
244
+ }
245
+
239
246
int String::compare ( size_type pos, size_type len, const String& str ) const {
240
247
int r = -1 ;
241
248
if (pos <= size_) {
0 commit comments