Use computed offset instead of hand-built array for access to struct swb_config members
authorSteven Luo <steven+maemo@steven676.net>
Sun, 28 Nov 2010 14:14:17 +0000 (06:14 -0800)
committerSteven Luo <steven+maemo@steven676.net>
Sun, 19 Dec 2010 19:11:19 +0000 (11:11 -0800)
commitfd200ff52e139d2180003a8711cbde56dd7e8126
tree9809ad617119d119d6f3dadbc81901ee45370cd3
parent3cc94f16ef41a2784c4185d52536f0d2e7c6610b
Use computed offset instead of hand-built array for access to struct swb_config members

To access an arbitrary member of struct swb_config, we currently use the
entries array in the struct, which contains pointers to the members of
the struct in order.  This has several disadvantages:

* the entries array must be filled by hand for each instance;
* structure instances cannot be copied in the normal way;
* the swb_config_options array describing the possible config options
  must be kept in the same order as the members of the struct.

A much better solution is to let the compiler compute the offset of
structure members using the offsetof() macro and stick the results in
the swb_config_options array; we can then access the member by adding
the offset to the address of the structure instance.  This also allows
us to get rid of the entries array in struct swb_config and the
swb_config_copy() function.
config-ui/browser-switchboard-config.c
config-ui/browser-switchboard-cp.c
config-ui/save-config.c
config.c
config.h