|
From: Olly B. <ol...@su...> - 2007-04-05 10:36:00
|
On Sat, Mar 31, 2007 at 12:35:42PM -0500, Stephen Torri wrote:
> Is this the correct us of VALGRIND_CHECK_MEM_IS_DEFINED? The macro wants
> a int and I am sending it the pointer to a const Component_Graph and a
> std::string.
>
> void Reverse_Impl::print_Graph
> ( infrastructure::Component_Graph const& graph_ref,
> std::string const name ) const
Incidentally, did you mean to pass name by reference here?
> {
> VALGRIND_CHECK_MEM_IS_DEFINED(&graph_ref,sizeof(graph_ref));
For the case of a variable, you can write that more simply as:
VALGRIND_CHECK_VALUE_IS_DEFINED(graph_ref);
(which expands via a macro to essentially the same thing).
> VALGRIND_CHECK_MEM_IS_DEFINED(&name,name.size());
That doesn't make sense - it checks "length of string" bytes from the
start of the string object. But the std::string will probably
(inevitably I think actually) not hold the string data directly
but via a pointer or series of pointers.
So you can check the object:
VALGRIND_CHECK_VALUE_IS_DEFINED(name);
And then the string contents:
VALGRIND_CHECK_MEM_IS_DEFINED(name.data(), name.size());
Cheers,
Olly
|