Skip to content

Added a check to ensure memory tools is working#16

Merged
wjwwood merged 3 commits intomasterfrom
is_working_check
Oct 23, 2018
Merged

Added a check to ensure memory tools is working#16
wjwwood merged 3 commits intomasterfrom
is_working_check

Conversation

@wjwwood
Copy link
Copy Markdown
Member

@wjwwood wjwwood commented Oct 12, 2018

Fixes #14

@wjwwood wjwwood added enhancement New feature or request in review labels Oct 12, 2018
@wjwwood wjwwood self-assigned this Oct 12, 2018
@wjwwood
Copy link
Copy Markdown
Member Author

wjwwood commented Oct 12, 2018

/cc @serge-nikulin

@wjwwood
Copy link
Copy Markdown
Member Author

wjwwood commented Oct 12, 2018

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status


#include "osrf_testing_tools_cpp/memory_tools/is_working.hpp"

#include <string>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: #include <cstdlib> for std::malloc/std::free.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.

memcpy(some_memory, str.c_str(), str.length());
memcpy((void *)side_effect, some_memory, str.length());
std::free(some_memory);
osrf_testing_tools_cpp::memory_tools::guaranteed_malloc(str);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I'll update it to modify that instance as well, thanks!

/// Get the current on_realloc callback if set, otherwise null.
OSRF_TESTING_TOOLS_CPP_MEMORY_TOOLS_PUBLIC
AnyMemoryToolsCallback
get_on_realloc();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we don't actually use get_on_realloc/get_on_calloc/get_on_free, should we bother exposing them? I generally like to only expose the things that I'm using, to keep the API smaller.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered the same thing, but I errored on the side of symmetry. So unless there's some other reason I'd opt to not touch it again.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine, we can leave it.

Signed-off-by: William Woodall <william@osrfoundation.org>
@wjwwood
Copy link
Copy Markdown
Member Author

wjwwood commented Oct 23, 2018

Thanks for the review, I think I addressed the feedback, can you please re-review when you get some time?

@wjwwood wjwwood requested a review from clalancette October 23, 2018 23:29
@wjwwood
Copy link
Copy Markdown
Member Author

wjwwood commented Oct 23, 2018

New CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@wjwwood wjwwood merged commit 4e12aa0 into master Oct 23, 2018
@wjwwood wjwwood deleted the is_working_check branch October 23, 2018 23:43
@wjwwood wjwwood removed the in review label Oct 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants