[Asterisk-Dev] Patching flags to bitfield structs

Michael Giagnocavo mgg-digium at atrevido.net
Wed Jan 19 10:27:03 MST 2005


OK, I'm rewriting some code to use the flag macros, and it's turning out to
be much messier overall than using a simple struct {foo:1; bar:1;} flags;.
But, I'm told we must use the flag macros for consistency, even across
inconsistent items (so it's required non-related settings (to save memory)
as well as a true related bitfield).

So all in all, I get the extra work of #defining everything, extra code to
set as well as test -- all to avoid a built-in intrinsic. 

I doubt it's personal preference: "if (ast_test_flag(myflags, MYFLAGS_FOO))"
versus "if (myflags.foo)". I understand it when you need a portable format.
But not for saving memory. Its akin to doing "if (istrue(foo))" (for an int)
versus "if (foo)". 

So, I'll volunteer to rewrite the flagified code that only uses flags to
save memory. This isn't making the code "inconsistent". It's making it
consistent with the intent of the variables. So, if I'm volunteering, and
make the changes, would this get any traction? Or will I just be wasting my
time?

Thanks,
Michael





More information about the asterisk-dev mailing list