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


No differences found