On 12/01/2023 06.21, Ryosuke Niwa via webkit-dev wrote:
I suggest we *stop using raw pointers and references in any local or heap stored variable*.

I don't think this is feasible for code using non-WebKit libraries, and would expect it to not apply to such cases.

For instance, many GLib and GStreamer objects are refcounted, and we even have smart pointers for them in WebKit: GRefPtr, which refs/unref using RAII, and GUniquePtr, which frees GLib non-refcounted objects.

We use both GRefPtr/GUniquePtr and raw pointers, but the meaning of each is different:

GRefPtr and GUniquePtr mean the code owns a reference, and will unref/free when the variable goes out of scope. Raw pointer means the code is borrowing a reference. The code will do something with the object, then leave it, without establishing ownership of a reference to it. This is especially the case for const raw pointers, which you are meant to use within scope and are not allowed to free() them, as you are just borrowing them.
webkit-dev mailing list

Reply via email to