[fpc-devel] Access Violation withnested DLL'scompiledbyFPC(andsome more info on bug #4538)
Jonas Maebe
jonas.maebe at elis.ugent.be
Thu Dec 15 10:25:07 CET 2005
On 15 dec 2005, at 05:45, L505 wrote:
> Why does it generate a DecStringRef before you assigned the string?
> What if it is the
> first time and you are already at 0, it can't decrement it to -1
> can it?
The reference count can never be zero, because when it becomes zero
the string is freed and replaced with a nil pointer. Calling
DecStringRef() on a nil pointer does nothing.
> Does the reference count start at 0, or 1?
All ansistring variables are initialised with nil.
> That seems like it isn't doing anything useful, since we are
> incrementing and
> decrementing by one, every time we assign a string.
An ansistring is a pointer which points to a string. Many different
ansistring variables can point to the same string, and then the
reference count of this ansistring will be equal to the amount of
ansistring variables pointing to it.
s := t; (-> reference count of ansistring to which s points is
decreased by 1 and freed if reference count became zero, the one to
which t points is increased by 1)
q := t; (-> reference count of ansistring to which q points is
decreased by 1 and freed if reference count became zero, the one to
which t points is again increased by 1)
Jonas
More information about the fpc-devel
mailing list