Charles.Forsyth20060303-partialeea662d19 years agoHistory
61 lines · 869 B · Text
RawDownload
.TH REF 10.2.SH NAMERef, incref, decref \- reference counts.SH SYNOPSIS.ta \w'\fLchar* 'u.PP.Bint	incref(Ref *r).PP.Bint	decref(Ref *r).SH DESCRIPTIONA.B Refstructure holds a reference count for a data structure:.IP.EXtypedef structstruct Ref{    Lock;    long ref;} Ref;.EE.PPThe reference count proper is found in.BR ref ;the.B Lockprevents concurrent updates(see.IR lock (10.2))..PP.I Increfatomically increments the reference count.IR r ,and returns the new count..PP.I Decrefatomically decrements the reference count.IR r ,and returns the new count..SH EXAMPLESRelease a structure containing a.B Refon last use..IP.EXif(decref(s) == 0)	free(s);.EE.SH DIAGNOSTICS.I Decrefwill.IR panic (10.2)if the count goes negative,revealing a reference counting bug..SH SOURCE.B /os/port/chan.c.br.B /emu/port/chan.c