Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SharedPtr::reset #9580

merged 1 commit into from Feb 4, 2019
Changes from all commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+5 −2
Diff settings


Just for now

Copy path View file
@@ -145,10 +145,13 @@ class SharedPtr {
// Clean up by decrementing counter

_ptr = ptr;
if (ptr != NULL) {
// Allocate counter on the heap, so it can be shared
_counter = new uint32_t;
*_counter = 1;
} else {
_counter = NULL;

@@ -226,16 +229,16 @@ class SharedPtr {
* @brief Decrement reference counter.
* @details If count reaches zero, free counter and delete object pointed to.
* Does not modify our own pointers - assumption is they will be overwritten
* or destroyed immediately afterwards.
void decrement_counter()
if (_ptr != NULL) {
uint32_t new_value = core_util_atomic_decr_u32(_counter, 1);
if (new_value == 0) {
delete _counter;
_counter = NULL;
delete _ptr;
_ptr = NULL;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.