Date: Monday, December 19, 2005 @ 17:14:14
Author: gilles
Path: /cvsroot/carob/carob/src
Modified: StringCodecs.cpp (1.1 -> 1.2)
Replaced GNU-compiler-specific syntax "char res[maxlength]" by usual new[]
------------------+
StringCodecs.cpp | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
Index: carob/src/StringCodecs.cpp
diff -u carob/src/StringCodecs.cpp:1.1 carob/src/StringCodecs.cpp:1.2
--- carob/src/StringCodecs.cpp:1.1 Thu Dec 15 21:01:17 2005
+++ carob/src/StringCodecs.cpp Mon Dec 19 17:14:14 2005
@@ -70,7 +70,7 @@
// (it's a memory/CPU tradeoff)
int res_maxlength = codecvt.max_length() * w_arg.length();
// TODO: rather use free store for big strings?
- char res_buf[res_maxlength];
+ char* res_buf = new char[res_maxlength];
const wchar_t *w_argnext;
char *res_next;
@@ -85,10 +85,12 @@
// TODO something sensible here: messages in the exception instead of
cerr
std::cerr << "Error " << success << " in "
<< loc.name() << " encode method" << std::endl;
+ delete[] res_buf;
throw CodecException();
}
-
- return std::string(res_buf, res_next-res_buf);
+ std::string retStr(res_buf, res_next-res_buf);
+ delete[] res_buf;
+ return retStr;
}
@@ -98,7 +100,7 @@
int arglength = arg.length();
// TODO: rather use free store for big strings?
- wchar_t wres_buf[arglength];
+ wchar_t* wres_buf = new wchar_t[arglength];
const char *argnext;
wchar_t *wres_next;
@@ -113,10 +115,12 @@
// TODO something sensible here: put messages in the exception instead
of cerr
std::cerr << "Error " << success << " in "
<< loc.name() << " decode method" << std::endl;
+ delete[] wres_buf;
throw CodecException();
}
-
- return std::wstring(wres_buf, wres_next-wres_buf);
+ std::wstring retWStr(wres_buf, wres_next-wres_buf);
+ delete wres_buf;
+ return retWStr;
}
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits