38 | | Sometimes it is desirable to store a pointer in a `GRefPtr` without increasing the reference counter. The main use case is assigning a newly created instance to a `GRefPtr`: the newly created instance already has a reference count of ''one'' and assigning it to a `GRefPtr` would increase the reference count to ''two'', which would be incorrect. To avoid this, the `adoptGRef()` helper function is provided. This function creates a `GRefPtr` without increasing the reference counter of the object it holds. This is incorrect: |
| 30 | === Adopting a reference === |
| 31 | |
| 32 | Sometimes it is desirable to store a pointer in a `GRefPtr` without increasing the reference counter. The main use case is assigning a newly created instance to a `GRefPtr`: the newly created instance already has a reference count of ''one'' and assigning it to a `GRefPtr` would increase the reference count to ''two'', which would be incorrect (and very likely would cause a leak). To avoid this, the `adoptGRef()` helper function is provided. This function creates a `GRefPtr` without increasing the reference counter of the object it holds. This is incorrect: |