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/projects.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/projects.h') diff --git a/src/projects.h b/src/projects.h index ca2cdbe3..63ea44da 100644 --- a/src/projects.h +++ b/src/projects.h @@ -713,8 +713,8 @@ double pj_qsfn_(double, PJ *); double *pj_authset(double); double pj_authlat(double, double *); -COMPLEX pj_zpoly1(COMPLEX, COMPLEX *, int); -COMPLEX pj_zpolyd1(COMPLEX, COMPLEX *, int, COMPLEX *); +COMPLEX pj_zpoly1(COMPLEX, const COMPLEX *, int); +COMPLEX pj_zpolyd1(COMPLEX, const COMPLEX *, int, COMPLEX *); int pj_deriv(LP, double, const PJ *, struct DERIVS *); int pj_factors(LP, const PJ *, double, struct FACTORS *); -- cgit v1.2.3