aboutsummaryrefslogtreecommitdiffhomepage
path: root/env_universal_common.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-02-22 12:00:02 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-02-22 12:00:02 -0800
commit376e199ebb562672f415e548c9d127b24117f905 (patch)
tree9f433eaec84d8b0987aa0c455c4f7585fb26273b /env_universal_common.cpp
parenta837a27b347e5c6b1669bbf83f7f0c0ce1c523df (diff)
Removed a lot of string_buffer_t
Diffstat (limited to 'env_universal_common.cpp')
-rw-r--r--env_universal_common.cpp23
1 files changed, 9 insertions, 14 deletions
diff --git a/env_universal_common.cpp b/env_universal_common.cpp
index 20eaccd4..d7dea877 100644
--- a/env_universal_common.cpp
+++ b/env_universal_common.cpp
@@ -736,30 +736,29 @@ void try_send_all( connection_t *c )
/**
Escape specified string
*/
-static wchar_t *full_escape( const wchar_t *in )
+static wcstring full_escape( const wchar_t *in )
{
- string_buffer_t out;
- sb_init( &out );
+ wcstring out;
for( ; *in; in++ )
{
if( *in < 32 )
{
- sb_printf( &out, L"\\x%.2x", *in );
+ append_format( out, L"\\x%.2x", *in );
}
else if( *in < 128 )
{
- sb_append_char( &out, *in );
+ out.push_back(*in);
}
else if( *in < 65536 )
{
- sb_printf( &out, L"\\u%.4x", *in );
+ append_format( out, L"\\u%.4x", *in );
}
else
{
- sb_printf( &out, L"\\U%.8x", *in );
+ append_format( out, L"\\U%.8x", *in );
}
}
- return (wchar_t *)out.buff;
+ return out;
}
@@ -803,12 +802,8 @@ message_t *create_message( int type,
val_in=L"";
}
- wchar_t *esc = full_escape( val_in );
- if( !esc )
- break;
-
- char *val = wcs2utf(esc );
- free(esc);
+ wcstring esc = full_escape( val_in );
+ char *val = wcs2utf(esc.c_str());
sz = strlen(type==SET?SET_MBS:SET_EXPORT_MBS) + strlen(key) + strlen(val) + 4;
msg = (message_t *)malloc( sizeof( message_t ) + sz );