[asterisk-dev] [svn-commits] lmadsen: branch 1.8 r300082 - /branches/1.8/pbx/pbx_dundi.c
Tilghman Lesher
tilghman at meg.abyt.es
Tue Jan 4 19:26:37 CST 2011
On Tuesday 04 January 2011 16:23:53 Russell Bryant wrote:
> On Tue, 2011-01-04 at 13:40 -0600, Tilghman Lesher wrote:
> > There's no benefit to using stringfields if the value does not change
> > past creation.
>
> The opposite, actually. String fields were not intended to be used at
> all for strings that change. The code was later updated to attempt to
> reclaim unused pools, but it shouldn't be relied upon.
I don't think that's actually true. That may be a side effect, but I
believe the original intent was to save space in structures where we have
a lot of strings, which may change over the lifetime of the structure. The
reason they're made into const strings is to push users into using the
supplied APIs, instead of trying to change the strings directly (because
they were originally static buffers, and external code needed to be made
to break, in order to force the authors to update their code).
> In the case of this structure, there are 3 strings that only get set a
> single time, which is the exact sort of situation where string fields
> should be used.
Generally, if those are the only strings in the structure, we then allocate
the strings as pointers and point to memory past the end of the formal
structure. It gives static memory checkers fits, but it ensures a single
malloc per structure.
--
Tilghman
More information about the asterisk-dev
mailing list