summaryrefslogtreecommitdiff
path: root/src/KM_fileio.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/KM_fileio.cpp')
-rw-r--r--src/KM_fileio.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/KM_fileio.cpp b/src/KM_fileio.cpp
index 50e01d6..e94525e 100644
--- a/src/KM_fileio.cpp
+++ b/src/KM_fileio.cpp
@@ -53,33 +53,33 @@ struct iovec {
typedef struct stat fstat_t;
#endif
+//
static void
split(const std::string& str, char separator, std::list<std::string>& components)
{
const char* pstr = str.c_str();
const char* r = strchr(pstr, separator);
- while( r != NULL )
+ while ( r != 0 )
{
- char* cp = new char[(r-pstr)+1];
- memcpy(cp, pstr, (r-pstr));
- cp[(r-pstr)] = '\0';
-
- if( strlen(cp) > 0 )
+ assert(r >= pstr);
+ if ( r > pstr )
{
- std::string s(cp);
- components.push_back(s);
+ std::string tmp_str;
+ assert(r - pstr < 100);
+ tmp_str.assign(pstr, (r - pstr));
+ components.push_back(tmp_str);
}
- delete[] cp;
pstr = r + 1;
r = strchr(pstr, separator);
}
if( strlen(pstr) > 0 )
- components.push_back(std::string(pstr));
+ components.push_back(std::string(pstr));
}
+
//
static Kumu::Result_t
do_stat(const char* path, fstat_t* stat_info)