mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-07-02 14:04:22 +00:00
Crash fix - make path on the fly
Newer versions of gcc have a small string optimizations that makes moving FileRecordData objects behave incorrectly. When a small string is moved, string_refs into it become invalid. Making a path on the fly using the path() method also has the side effect of making FileRecordData smaller in size.
This commit is contained in:
parent
21c5b3efcb
commit
8c03ba15bc
5 changed files with 24 additions and 21 deletions
|
@ -39,11 +39,11 @@ namespace mchlib {
|
|||
mime_full(),
|
||||
atime(parATime),
|
||||
mtime(parMTime),
|
||||
path(abs_path),
|
||||
mime_type(),
|
||||
mime_charset(),
|
||||
size(0),
|
||||
level(parLevel),
|
||||
path_offset(0),
|
||||
is_directory(parIsDir),
|
||||
is_symlink(parIsSymLink),
|
||||
unreadable(false),
|
||||
|
@ -51,22 +51,23 @@ namespace mchlib {
|
|||
{
|
||||
}
|
||||
|
||||
FileRecordData ( std::string&& parPath, std::size_t parRelPathOffs, std::time_t parATime, std::time_t parMTime, uint16_t parLevel, bool parIsDir, bool parIsSymLink ) :
|
||||
FileRecordData ( std::string&& parPath, uint16_t parRelPathOffs, std::time_t parATime, std::time_t parMTime, uint16_t parLevel, bool parIsDir, bool parIsSymLink ) :
|
||||
hash {},
|
||||
abs_path(std::move(parPath)),
|
||||
mime_full(),
|
||||
atime(parATime),
|
||||
mtime(parMTime),
|
||||
path(boost::string_ref(abs_path).substr(parRelPathOffs)),
|
||||
mime_type(),
|
||||
mime_charset(),
|
||||
size(0),
|
||||
level(parLevel),
|
||||
path_offset(parRelPathOffs),
|
||||
is_directory(parIsDir),
|
||||
is_symlink(parIsSymLink),
|
||||
unreadable(false),
|
||||
hash_valid(false)
|
||||
{
|
||||
assert(path_offset <= abs_path.size());
|
||||
}
|
||||
|
||||
#if defined(NDEBUG)
|
||||
|
@ -81,16 +82,18 @@ namespace mchlib {
|
|||
bool operator== ( const FileRecordData& parOther ) const;
|
||||
#endif
|
||||
|
||||
boost::string_ref path ( void ) const { return boost::string_ref(abs_path).substr(path_offset); }
|
||||
|
||||
TigerHash hash;
|
||||
std::string abs_path;
|
||||
mime_string mime_full;
|
||||
std::time_t atime;
|
||||
std::time_t mtime;
|
||||
boost::string_ref path;
|
||||
boost::string_ref mime_type;
|
||||
boost::string_ref mime_charset;
|
||||
uint64_t size;
|
||||
uint16_t level;
|
||||
uint16_t path_offset; //Relative path starting character into abs_path
|
||||
bool is_directory;
|
||||
bool is_symlink;
|
||||
bool unreadable;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue