diff options
author | Charles Curley <charlescurley@charlescurley.com> | 2017-12-06 17:03:22 -0700 |
---|---|---|
committer | Charles Curley <charlescurley@charlescurley.com> | 2017-12-06 17:03:22 -0700 |
commit | ba18a5d41964b58788e35432e54a641565690282 (patch) | |
tree | 10190f34900baa0d43da42fd13fd85a0d1670810 | |
parent | ca6dbc32a1d6ad196e762e9f88277757a8ae13c7 (diff) | |
download | navit-ba18a5d41964b58788e35432e54a641565690282.tar.gz |
Added a comment on this method of calculating the number of elements
in an array (#define SIZE_OF_ARRAY_DISTANCES).
comment:navit:navigation.c
modified: navit/navigation.c
-rw-r--r-- | navit/navigation.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/navit/navigation.c b/navit/navigation.c index be894c7ed..a31ee8459 100644 --- a/navit/navigation.c +++ b/navit/navigation.c @@ -194,6 +194,22 @@ struct navigation { /** @brief Set of simplified distance values that are easy to be pronounced. * Used for the 'vocabulary_distances' configuration. */ + +/** + * This method of calculating the number of elements in an array + * (#define SIZE_OF_ARRAY_DISTANCES, below) will work for most modern + * processors. It may cause problems on a few obscure processors, none + * of which are likely candidates for navit anyway. + * + * It works like so: Modern processors simply stuff the elements of an + * int array into memory one after the other, with no gaps. Some older + * processors might not do so, due to memory alignment issues. This + * method does not take such gaps into account. For more discussion, + * see https://github.com/navit-gps/navit/pull/373 + * + * So if you are on an oddball processor and start getting really odd + * values for distances, this might be the reason. Good luck! + */ const int distances[]={1,2,3,4,5,10,25,50,75,100,150,200,250,300,400,500,750}; #define SIZE_OF_ARRAY_DISTANCES (sizeof (distances)/sizeof (int)) #define LAST_DISTANCE (SIZE_OF_ARRAY_DISTANCES - 1) |