Bill Sommerfeld wrote:
> 
> is there some reason why you didn't define a xfrtn_t (since the function
> signature of the free callback is different), and why you didn't use a
> function signature of:
> 
> boolean_t (*free_func)(caddr_t) 
> 
> (returning B_TRUE or B_FALSE as appropriate)
> 
> the former seems appropriate from a cleanliness perspective (give the
> compiler a better chance to catch type mismatches); the latter seems
> simpler and my vague recollection was that it was slightly more
> efficient as well.  

The problem is that the db_frtn field of the dblk_t is defined as a 
frtn_t *. If I created a new structure type then I'd have to cast it 
anyway to assign it to that field, or change the typedef of dblk_t to 
union the two pointer types together and then #define something do that 
db_frtn still pointed at the frtn_t element. I could do this, but I was 
uneasy about changing the typedef of dblk_t.
The fact that the definition frtn_t.free_func does not specify the 
arguments to the function seemed like a gift allowing me to keep the 
code changes to the minimum. The use of an incorrectly defined free_func 
that does not specify the second argument can also be made safe, as I 
stated, by the fact that if the boolean remains unmodified then the 
semantics are identical to desballoc() whereas a function that returns a 
void ending up being cast to one that returns a boolean would be bad.

   Paul


Reply via email to