From: Steven Luo Date: Sun, 28 Nov 2010 14:14:17 +0000 (-0800) Subject: Use computed offset instead of hand-built array for access to struct swb_config members X-Git-Url: http://git.maemo.org/git/?p=browser-switch;a=commitdiff_plain;h=fd200ff52e139d2180003a8711cbde56dd7e8126;hp=fd200ff52e139d2180003a8711cbde56dd7e8126;ds=sidebyside 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. ---