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

Luigi Rizzo rizzo at icir.org
Mon Nov 26 16:05:51 CST 2007

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).


More information about the asterisk-dev mailing list