get rid of numerous probably inocuous valgrind/helgrind messages by ensuring that actual string copies are passed between threads, without refcount/shared data magic

This commit is contained in:
Jean-Francois Dockes
2014-05-05 19:01:58 +02:00
parent deb4cc8d12
commit e867f855ad
8 changed files with 73 additions and 17 deletions
+12 -5
View File
@@ -30,6 +30,18 @@
using namespace std;
#endif /* NO_NAMESPACES */
// Bogus code to avoid bogus valgrind mt warnings about the
// initialization of treat_mbox_... which I can't even remember the
// use of (it's not documented or ever set)
static int treat_mbox_as_rfc822;
class InitTMAR {
public:
InitTMAR() {
treat_mbox_as_rfc822 = getenv("RECOLL_TREAT_MBOX_AS_RFC822") ? 1 : -1;
}
};
static InitTMAR initTM;
/**
* This code is currently ONLY used to identify mbox and mail message files
* which are badly handled by standard mime type identifiers
@@ -49,11 +61,6 @@ const int wantnhead = 3;
// fn is for message printing
static string idFileInternal(istream& input, const char *fn)
{
static int treat_mbox_as_rfc822;
if (treat_mbox_as_rfc822 == 0) {
treat_mbox_as_rfc822 = getenv("RECOLL_TREAT_MBOX_AS_RFC822") ? 1 : -1;
}
bool line1HasFrom = false;
bool gotnonempty = false;
int lookslikemail = 0;
+10
View File
@@ -42,6 +42,16 @@ using namespace std;
#include "hldata.h"
#include "cstr.h"
void map_ss_cp_noshr(const map<string,string> s, map<string,string> *d)
{
for (map<string,string>::const_iterator it= s.begin();
it != s.end(); it++) {
d->insert(
pair<string,string>(string(it->first.begin(), it->first.end()),
string(it->second.begin(), it->second.end())));
}
}
int stringicmp(const string & s1, const string& s2)
{
string::const_iterator it1 = s1.begin();
+5
View File
@@ -197,6 +197,11 @@ inline void leftzeropad(string& s, unsigned len)
s = s.insert(0, len - s.length(), '0');
}
// Duplicate map<string,string> while ensuring no shared string data (to pass
// to other thread):
void map_ss_cp_noshr(const std::map<std::string,std::string> s,
std::map<std::string,std::string> *d);
// Code for static initialization of an stl map. Somewhat like Boost.assign.
// Ref: http://stackoverflow.com/questions/138600/initializing-a-static-stdmapint-int-in-c
// Example use: map<int, int> m = create_map<int, int> (1,2) (3,4) (5,6) (7,8);