From a07501a165e6f2521c9aa13fa63fab33cf67d876 Mon Sep 17 00:00:00 2001 From: Aaron Puchert Date: Fri, 17 Nov 2017 17:46:34 +0100 Subject: Declare non-local variables as const where possible Having non-const variables of static lifetime or even global scope is usually a bad idea. These variables are inherently constants, and this should be enforced. This required marking some functions as not modifying input parameters and marking some pointers as pointers to const. One advantage is that the compiler usually puts const static variables in a read-only code segment, so they can't be modified physically. This can be verified with `nm` (on POSIX systems). To avoid changes to the public API, functions returning non-const pointers to data tables were left intact, but the returned data may not be modified. Internally we prefer using the proj_list_* functions over the pj_get_*_ref functions, because the former return const pointers. --- src/proj_4D_api.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) (limited to 'src/proj_4D_api.c') diff --git a/src/proj_4D_api.c b/src/proj_4D_api.c index 0fba5097..a0550727 100644 --- a/src/proj_4D_api.c +++ b/src/proj_4D_api.c @@ -597,7 +597,7 @@ PJ_INFO proj_info(void) { ******************************************************************************/ PJ_INFO info; - const char **paths; + const char * const *paths; char *tmpstr; int i, n; size_t len = 0; @@ -847,20 +847,3 @@ PJ_FACTORS proj_factors(PJ *P, LP lp) { return factors; } - -const PJ_ELLPS *proj_list_ellps(void) { - return pj_get_ellps_ref(); -} - -const PJ_UNITS *proj_list_units(void) { - return pj_get_units_ref(); -} - -const PJ_OPERATIONS *proj_list_operations(void) { - return pj_get_list_ref(); -} - -const PJ_PRIME_MERIDIANS *proj_list_prime_meridians(void) { - return pj_get_prime_meridians_ref(); -} - -- cgit v1.2.3