Update of bug #13805 (project freeciv): Assigned to: None => mbook
_______________________________________________________ Follow-up Comment #1: This patch is good, but you can reduce references to the global variable 'settings' even more by using helper functions to get a setting pointer from a setting id: struct settings_s *setting_by_number(int id) { if (!(0 <= id && id < SETTINGS_NUM) { return NULL; } return settings + id; } (The expression 'settings + id' is the same as '&settings[id]', since ptr[x] == *(ptr + x)). To get the "id" from a setting pointer, you use pointer arithmetic again: int setting_number(const struct setting_s *op) { if (!op) { return -1; } return op - settings; } Some description of pointer arithmetic is here http://en.wikipedia.org/wiki/Pointer_arithmetic#C_and_C.2B.2B if you are unfamiliar with the concept. Ideally we would want to completely remove the extern reference to 'settings' from settings.h. Good job using git. :) ---------------------------------------------------------------- 算数授業に行きましょうか。 _______________________________________________________ Reply to this item at: <http://gna.org/bugs/?13805> _______________________________________________ Message sent via/by Gna! http://gna.org/ _______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev