Hi,
This discusion came up multiple times on Bugzilla so I'm posting it here.
When a member function f() of a RefCounted object can end up removing the
last ref to the object itself, should we do:
void Foo::f() {
RefPtr<Foo> protect(this);
}
or
RefPtr<Foo> foo = rawPointerToFoo;
foo->f()
in its call site.
The first approach guarantees that any call to f() is safe while the second
approach is future proof if we add more code to use foo after calling f().
I think it's good to agree on one convention here since managing lifetime
of objects is tricky, and having one convention will make it easier to
reason about things.
- R. Niwa
_______________________________________________
webkit-dev mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-dev