[asterisk-dev] [asterisk-commits] murf: trunk r89591 - /trunk/main/hashtab.c

Steve Murphy murf at parsetree.com
Tue Nov 27 14:45:22 CST 2007

On Mon, 2007-11-26 at 14:05 -0800, Luigi Rizzo wrote:
> On Mon, Nov 26, 2007 at 12:50:13PM -0600, Kevin P. Fleming wrote:
> > Luigi Rizzo wrote:
> > 
> > > But while we are on the subject, i'd really use a typedef for the
> > > various function pointers involved - having function prototypes
> > > as arguments of a function is really horrible C.
> > 
> > Why? The typedefs are useless, unless you are declaring many instance
> > variables that can hold those function pointers. In this case there are
> > only two definitions (in the structure and in the argument list) so the
> > typedef is just pointless obfuscation.
> There is a ton of potential uses for such prototypes.
> In addition to the structure, the arglist is both in the .h and the
> .c file, and there is also a large number of compare (4),
> resize(3), newsize(3) and hash (5) functions in both the .c and .h
> So each prototype would be used between 9 and 13 times.
> This said, i also have some reservations on the API itself - there is
> no point to define two different functions for resize and newsize
> when the usage is just "if (resize()) { x = newsize(); ...use x }".
> It would be a lot easier to use a single functions that returns
> the new desired size, and act on its value to see if we need to resize
> or not: simpler API, probably marginally faster too (only one call instead
> of two).

I've wrestled with this both ways. My original thought was if the
newsize calls were intensive, you could skip making them so frequently
this way. But they rarely are that intensive. Perhaps I will pull them
together. I don't see this as critical at the moment.

Using the prototype isn't that bad an idea, either.

Thanks, Luigi!

> cheers
> luigi

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3239 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-dev/attachments/20071127/a0484148/attachment.bin 

More information about the asterisk-dev mailing list