[splint-discuss] How do I treat a symbol table?
Terry Colligan
terry-splint at tenberry.com
Tue Aug 23 14:49:27 EDT 2005
On Tuesday 23 August 2005 11:07 am, Tommy Pettersson wrote:
> On Tue, Aug 23, 2005 at 10:02:37AM -0700, Terry Colligan wrote:
> > One of my problems is how to treat a symbol table. I need
> > mostly to add malloc'd copies of strings to the symbol table,
> > but the symbol table is initialized with some string literals.
> >
> > The code:
> [...]
>
> I looks like you aren't planning to release any of the memory
> owned by the symbol table, since you add pointers to string
> literals to it with no special markings.
That's currently true, but I could add two routines -- one
for static string literals, and one for malloc'd strings.
> Then it doesn't make so
> much sense to track the release responsibility (with /*@keep@*/
> et.al.).
I got sucked into using /*@keep@*/ because of the situations
where the stored string was, in fact, dynamically allocated.
I need an annotation-based solution, rather than a flag-based
solution, because I don't want to lose the checking for other
dynamically-allocated pointers.
> I think there are some splint markups for garbage
> collection drive memory handling, so pointers can be used freely
> but not for releasing the memory. I have never tried it, I'm not
> sure my memory serves me right, and I don't have time to look it
> up now, sorry. It's just an idea, not necessarily a good one.
I found what you mentioned: the 'shared' attribute.
Changing the 'keep' attribute to 'shared' seems to solve
this problem.
Thanks to Tommy and to Luke Imhoff, who also suggested 'shared'
attribute.
--
Terry
Terry Colligan terry-splint at tenberry.com
More information about the splint-discuss
mailing list