On 27 May 2010, newlifewi...@gmail.com wrote:

> I am reading Splint Manual for Memory Management Bugs and not getting
> any clue on following Annotations:
> 1:only
> 2:owned
> 3:dependent
> 4:refcounted

> The problem I am facing with the examples within the manual.It is hard
> to understand.So it will be helpful if you guys provide me easy to
> understand examples.
> Thanks,Ajay

The manual assumes familiarity with several design patterns.  See this link,

  http://www.informit.com/articles/article.aspx?p=30309

The 'only' annotation is for pool and fixed sized patterns.  This
includes the typical 'C' malloc/free.

The 'refcounted' can be used to implement a pseudo-garbage collection
in 'C'.  Reference counting is also a method to implement smart
pointers.  C++ will do this with very little developer interaction
(and code will be silently generated), where as developers have to do
some of this manual in 'C'.

Dependent and owned are not outlined as a design pattern above.  The
are useful in an object-orient allocation strategy in 'C'.  That is
some principal structure is the object (owns it) and something else is
only using it (dependent on the owner having created it).

Generally unless you are very sophisticated (and a masochist), you
will only need the 'only' annotation.  The owned/dependent might be
useful if you are using object-oriented principals in 'C'.  In 'C' you
have to manually increment/decrement a reference count.  However,
there can be several users of the same 'object' (structure, array,
etc).  This can be useful if there is no concrete owner of an object,
but several different things might make use of it.  Refcounted is like
a 'multiple owner'.  The more complex schemes are difficult to get
right in a multi-threaded environment and *probably* aren't as useful
if you don't have threads.

hth,
Bill Pringlemeir.

-- 
Yow!  Legally-imposed CULTURE-reduction is CABBAGE-BRAINED!
_______________________________________________
splint-discuss mailing list
splint-discuss@mail.cs.virginia.edu
http://www.cs.virginia.edu/mailman/listinfo/splint-discuss

Reply via email to