Skip to main content
`Ctrl`+`K`

# PetscObjectReference

Indicates to a `PetscObject` that it is being referenced by another `PetscObject`. This increases the reference count for that object by one.

## Synopsis

    #include "petscsys.h"
    PetscErrorCode PetscObjectReference(PetscObject obj)

Logically Collective

## Input Parameter

- obj - the PETSc object. This must be cast with (`PetscObject`), for example, `PetscObjectReference`((`PetscObject`)mat);

## Note

If `obj` is `NULL` this function returns without doing anything.

## See Also

`PetscObjectCompose()`, `PetscObjectDereference()`, `PetscObject`

## Level

advanced

## Location

src/sys/objects/inherit.c

## Examples

src/ts/tutorials/ex30.c
src/ts/tutorials/ex3.c
src/ksp/ksp/tutorials/ex35.cxx
src/ts/tutorials/ex11.c
src/ksp/ksp/tutorials/ex42.c
src/ksp/ksp/tutorials/ex73.c
src/snes/tutorials/ex73f90t.F90
src/ksp/ksp/tutorials/ex36.cxx

Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages