aboutsummaryrefslogtreecommitdiff
path: root/src/PJ_mod_ster.c
diff options
context:
space:
mode:
authorAaron Puchert <aaron.puchert@sap.com>2017-11-17 17:46:34 +0100
committerAaron Puchert <aaronpuchert@alice-dsl.net>2017-12-17 23:34:40 +0100
commita07501a165e6f2521c9aa13fa63fab33cf67d876 (patch)
tree846a2df69948cb6d4927c0c8d5b953786df5cb04 /src/PJ_mod_ster.c
parent95f8e749e712218ca49e4025fe6ab59ddf991c60 (diff)
downloadPROJ-a07501a165e6f2521c9aa13fa63fab33cf67d876.tar.gz
PROJ-a07501a165e6f2521c9aa13fa63fab33cf67d876.zip
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.
Diffstat (limited to 'src/PJ_mod_ster.c')
-rw-r--r--src/PJ_mod_ster.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/PJ_mod_ster.c b/src/PJ_mod_ster.c
index c8e4c6b8..d807660c 100644
--- a/src/PJ_mod_ster.c
+++ b/src/PJ_mod_ster.c
@@ -12,7 +12,7 @@ PROJ_HEAD(gs50, "Mod. Stereographic of 50 U.S.") "\n\tAzi(mod)";
#define EPSLN 1e-12
struct pj_opaque {
- COMPLEX *zcoeff; \
+ const COMPLEX *zcoeff; \
double cchio, schio; \
int n;
};
@@ -120,7 +120,7 @@ static PJ *setup(PJ *P) { /* general initialization */
/* Miller Oblated Stereographic */
PJ *PROJECTION(mil_os) {
- static COMPLEX AB[] = {
+ static const COMPLEX AB[] = {
{0.924500, 0.},
{0., 0.},
{0.019430, 0.}
@@ -143,7 +143,7 @@ PJ *PROJECTION(mil_os) {
/* Lee Oblated Stereographic */
PJ *PROJECTION(lee_os) {
- static COMPLEX AB[] = {
+ static const COMPLEX AB[] = {
{0.721316, 0.},
{0., 0.},
{-0.0088162, -0.00617325}
@@ -165,7 +165,7 @@ PJ *PROJECTION(lee_os) {
PJ *PROJECTION(gs48) {
- static COMPLEX /* 48 United States */
+ static const COMPLEX /* 48 United States */
AB[] = {
{0.98879, 0.},
{0., 0.},
@@ -191,7 +191,7 @@ PJ *PROJECTION(gs48) {
PJ *PROJECTION(alsk) {
- static COMPLEX ABe[] = { /* Alaska ellipsoid */
+ static const COMPLEX ABe[] = { /* Alaska ellipsoid */
{ .9945303, 0.},
{ .0052083, -.0027404},
{ .0072721, .0048181},
@@ -200,7 +200,7 @@ PJ *PROJECTION(alsk) {
{ .3582802, -.2884586},
};
- static COMPLEX ABs[] = { /* Alaska sphere */
+ static const COMPLEX ABs[] = { /* Alaska sphere */
{ .9972523, 0.},
{ .0052513, -.0041175},
{ .0074606, .0048125},
@@ -231,7 +231,7 @@ PJ *PROJECTION(alsk) {
PJ *PROJECTION(gs50) {
- static COMPLEX ABe[] = { /* GS50 ellipsoid */
+ static const COMPLEX ABe[] = { /* GS50 ellipsoid */
{ .9827497, 0.},
{ .0210669, .0053804},
{-.1031415, -.0571664},
@@ -244,7 +244,7 @@ PJ *PROJECTION(gs50) {
{-.0210072, .0834037}
};
- static COMPLEX ABs[] = { /* GS50 sphere */
+ static const COMPLEX ABs[] = { /* GS50 sphere */
{ .9842990, 0.},
{ .0211642, .0037608},
{-.1036018, -.0575102},