apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Schaefer <joe+gm...@sunstarsys.com>
Subject optional function pointer casts to/from (void *)
Date Mon, 13 Sep 2004 21:18:40 GMT

This may be a bit pedantic, but I was looking over
the optional function implementation in apr_hooks.c
and noticed a few casts between void * and (void)(*)(void).
Technically this isn't legal in C, because the specs
don't guarantee that function pointers are "compatible"
(read: same size) with data pointers like (void *).

It should be easy enough to correct this by introducing
a private dummy wrapper struct like

  struct apr_dynamic_fn_ptr {

The struct can be allocated and added to the hash as a (void *)
during apr_dynamic_fn_register, and the function pointer can
then be pulled out of the struct during apr_dynamic_fcn_retrieve.
This would replace the incompatible casts in those functions.

I'd be happy to write up the patch for this if there's 
any interest.

Joe Schaefer

View raw message