On Tue, 24 Jul 2012 12:07:55 +0200 Simon Toedt wrote: > Can I deallocate individual strings in a sfio stream? How long is the > lifetime of a string in a sfio string stream anyway, i.e. when is it > deallocated? How does sfseek() affect this?
it depends on whether you use stk*() or sfstr*() in general though they each are conceptually a linear stream of bytes seek operations can shrink the virtual length but the underlying allocated chunks will remain for the life of the stream stkset() can return allocated data after the current object sfstr*() does not have a way to return unused data other then sfstrclose() if you have a situation like ^ used ^ not-used ^ used ^ the not-used will still take up allocated space -- i.e., not-used is a caller concept, not an sfio concept w.r.t. string streams nmake will typically juggle 1 <= n < 10 string streams, each from a separate sfstropen() the most common operation is to read from one string stream apply a transformation and write to another string stream for both stk*() and sfstr*() you can seek to the beginning of the stream this puts the stream in an initial state, ready for writing another ast paradigm is to use vmalloc(3) regions for building complex data structures each piece can be allocated by separate allocations, and vmfree() will also return unused space to the region -- when you are done just call vmclose() and everything is returned -- this libast code uses this method: src/lib/libast/misc/fastfind.c src/lib/libast/misc/magic.c src/lib/libast/misc/mc.c _______________________________________________ ast-developers mailing list ast-developers@research.att.com https://mailman.research.att.com/mailman/listinfo/ast-developers