[Asterisk-Dev] potentially nasty bugs in string pools usage

Luigi Rizzo rizzo at icir.org
Fri Jan 6 12:32:59 MST 2006


On Fri, Jan 06, 2006 at 11:47:02AM -0600, Kevin P. Fleming wrote:
> Steve Murphy wrote:
...
> > In the application I did this for, I found a 10:1 ratio of commonality
> > of strings entered. Thus, the savings on heap space of about 90%... your
> > mileage may vary considerably, but in general, string pools like this
> > are great, they reduce memory requirements, they speed things up by not
> > calling malloc/free as much, they reduce the complexity of your
> > interface, as far as copying a string vs. storing the address of the
> > string type issues. 
> 
> And they also allow for very, very fast string comparisons, since you 
> only need to compare the string pointers.

i wouldn't bet money on the fact we can actually exploit this at large.
most of the string comparisons in asterisk are strncasecmp,
which doesn't let us do the above...

also, this prevents the use of per-object pools, which poses different
locking issues on the allocator. Not that it cannot be done, it's just
different from what is going in now. Yet another reason why i don't
understand the use of per-object pools.

	cheers
	luigi



More information about the asterisk-dev mailing list