in xxxx.h file:
struct dn_instance_pair
{
std::string theDn;
int theInstance;
};
typedef struct dn_instance_pair t_dn_inst_pair;
struct table_rowid_type
{
char theTable[101];
sqlite3_int64 theRowid;
int operation;
};
// static class members
static vector<t_dn_inst_pair> dninstList;
static vector<t_table_rowid_type> tablerowidList;
in xxxx.cpp
// declaration of vectors.
// Included to this post only for completeness.
vector<t_dn_inst_pair> xxxx::dninstList;
vector<t_table_rowid_type> xxxx::tablerowidList;
These vectors are handled in static callback functions, so they must be static too.
In cpputest, when trying to add something in either one of these vectors, a failure happens:
Leak size: 8 Allocated at: <unknown> and line: 0. Type: "new" Content: "<\ufffdP@"
The stuff added to a vector are automatic variables and it happens in a normal function:
t_dn_inst_pair thePair;
thePair.theDn = updated_dn;
thePair.theInstance = updated_instance;
The vector is cleared in the end of the test case:
xxxx::yyyy()->dninstList.clear();
(yyyy() returns a pointer to a singleton xxxx object)
Page http://blog.objectmentor.com/articles/2010/02/04/cpputest-recent-experiences discusses the same kind of memory leak:
"This is a false positive. This is a one-time allocation and a side-effect of C++ memory allocation and static initialization."
So my question is: Is this failure genuinely a false positive ?
br Esko