[Modcplusplus-devel] (johnksterling) mod_cplusplus/src cpp_request.cpp
Brought to you by:
gr84b8,
johnksterling
|
From: Mod C. C. L. <mod...@so...> - 2004-08-27 13:09:07
|
Mod Cplusplus CVS committal
Author : johnksterling
Project : mod_cplusplus
Module : src
Dir : mod_cplusplus/src
Modified Files:
cpp_request.cpp
Log Message:
rework 3 things: 1) use snprintf instead of sprintf 2) use result from snprintf to build the string (optimization) 3) make utility methods private instance methods to protect them
===================================================================
RCS file: /cvsroot/modcplusplus/mod_cplusplus/src/cpp_request.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- cpp_request.cpp 31 Jul 2004 13:58:07 -0000 1.6
+++ cpp_request.cpp 27 Aug 2004 13:08:59 -0000 1.7
@@ -30,19 +30,17 @@
}
// translate integer to ascii string
-inline string
-istring(int value, const char* format = "%d")
+string ApacheRequestRec::istring(int value, const char* format) const
{
enum { TEMP_STORE = 50 };
char temp[TEMP_STORE];
- sprintf(temp,format,value);
- return string(temp);
+ const int len = snprintf(temp, TEMP_STORE, format, value);
+ return string(temp, len);
}
// translate non-NULL char* to string, NULL to empty string
-inline string
-mstring(const char *cp)
+string ApacheRequestRec::mstring(const char *cp) const
{
return cp ? cp : string();
}
|