{"action":"created","issue":{"url":"https://api.github.com/repos/proj4-bot/proj.4/issues/97","labels_url":"https://api.github.com/repos/proj4-bot/proj.4/issues/97/labels{/name}","comments_url":"https://api.github.com/repos/proj4-bot/proj.4/issues/97/comments","events_url":"https://api.github.com/repos/proj4-bot/proj.4/issues/97/events","html_url":"https://github.com/proj4-bot/proj.4/issues/97","id":79323726,"number":97,"title":"biveval.c is not reentrant","user":{"login":"proj4-bot","id":12542084,"avatar_url":"https://avatars.githubusercontent.com/u/12542084?v=3","gravatar_id":"","url":"https://api.github.com/users/proj4-bot","html_url":"https://github.com/proj4-bot","followers_url":"https://api.github.com/users/proj4-bot/followers","following_url":"https://api.github.com/users/proj4-bot/following{/other_user}","gists_url":"https://api.github.com/users/proj4-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/proj4-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/proj4-bot/subscriptions","organizations_url":"https://api.github.com/users/proj4-bot/orgs","repos_url":"https://api.github.com/users/proj4-bot/repos","events_url":"https://api.github.com/users/proj4-bot/events{/privacy}","received_events_url":"https://api.github.com/users/proj4-bot/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/proj4-bot/proj.4/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/proj4-bot/proj.4/labels/C:%20Core","name":"C: Core","color":"0000aa"},{"url":"https://api.github.com/repos/proj4-bot/proj.4/labels/P:%20major","name":"P: major","color":"f6f6f6"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-05-22T06:58:15Z","updated_at":"2015-05-22T06:58:53Z","closed_at":null,"body":"**Reported by runeaa on 23 Jan 2009 09:39 UTC**\nI suggest removing the static variables used for value passing between functions in biveval.c with ordinary function arguments to make it reentrant. Proposed changed file:\r\n```\r\n/* procedures for evaluating Tseries */\r\n#ifndef lint\r\nstatic const char SCCSID[      4.4     93/06/12        GIE     REL\";\r\n#endif\r\n# include <projects.h>\r\n# define NEAR_ONE       1.00001\r\nstatic double ceval(struct PW_COEF *C, int n, projUV w, projUV w2) {\r\n        double d=0, dd=0, vd, vdd, tmp, *c;\r\n        int j;\r\n\r\n        for (C += n ; n-- ; --C ) {\r\n                if (j = C->m) {\r\n                        vd = vdd = 0.;\r\n                        for (c = C->c + --j; j ; --j ) {\r\n                                vd = w2.v * (tmp = vd) - vdd + *c--;\r\n                                vdd = tmp;\r\n                        }\r\n                        d = w2.u * (tmp = d) - dd + w.v * vd - vdd + 0.5 * *c;\r\n                } else\r\n                        d = w2.u * (tmp = d) - dd;\r\n                dd = tmp;\r\n        }\r\n        if (j = C->m) {\r\n                vd = vdd = 0.;\r\n                for (c = C->c + --j; j ; --j ) {\r\n                        vd = w2.v * (tmp = vd) - vdd + *c--;\r\n                        vdd = tmp;\r\n                }\r\n                return (w.u * d - dd + 0.5 * ( w.v * vd - vdd + 0.5 * *c ));\r\n        } else\r\n                return (w.u * d - dd);\r\n}\r\n        projUV /* bivariate Chebyshev polynomial entry point */\r\nbcheval(projUV in, Tseries *T) {\r\n        projUV w2, w;\r\n        projUV out;\r\n                /* scale to +-1 */\r\n        w.u = ( in.u + in.u - T->a.u ) * T->b.u;\r\n        w.v = ( in.v + in.v - T->a.v ) * T->b.v;\r\n        if (fabs(w.u) > NEAR_ONE || fabs(w.v) > NEAR_ONE) {\r\n                out.u = out.v = HUGE_VAL;\r\n                pj_errno = -36;\r\n        } else { /* double evaluation */\r\n                w2.u = w.u + w.u;\r\n                w2.v = w.v + w.v;\r\n                out.u = ceval(T->cu, T->mu, w, w2);\r\n                out.v = ceval(T->cv, T->mv, w, w2);\r\n        }\r\n        return out;\r\n}\r\n        projUV /* bivariate power polynomial entry point */\r\nbpseval(projUV in, Tseries *T) {\r\n        projUV out;\r\n        double *c, row;\r\n        int i, m;\r\n\r\n        out.u = out.v = 0.;\r\n        for (i = T->mu; i >= 0; --i) {\r\n                row = 0.;\r\n                if (m = T->cu[i](]=\"@(#)biveval.c).m) {\r\n                        c = T->cu[+ m;\r\n                        while (m--)\r\n                                row = *--c + in.v * row;\r\n                }\r\n                out.u = row + in.u * out.u;\r\n        }\r\n        for (i = T->mv; i >= 0; --i) {\r\n                row = 0.;\r\n                if (m = T->cv[i](i].c).m) {\r\n                        c = T->cv[i].c + m;\r\n                        while (m--)\r\n                                row = *--c + in.v * row;\r\n                }\r\n                out.v = row + in.u * out.v;\r\n        }\r\n        return out;\r\n}\r\n\r\nprojUV /* general entry point selecting evaluation mode */\r\nbiveval(projUV in, Tseries *T) {\r\n\r\n    if (T->power) {\r\n        return bpseval(in, T);\r\n    } else {\r\n        return bcheval(in, T);\r\n    }\r\n}\r\n```\r\n\r\n\n\n*Last Modified by warmerdam on 23 Jan 2009 14:53 UTC*\n\n\nMigrated-From: https://trac.osgeo.org/proj/ticket/24"},"comment":{"url":"https://api.github.com/repos/proj4-bot/proj.4/issues/comments/104541531","html_url":"https://github.com/proj4-bot/proj.4/issues/97#issuecomment-104541531","issue_url":"https://api.github.com/repos/proj4-bot/proj.4/issues/97","id":104541531,"user":{"login":"proj4-bot","id":12542084,"avatar_url":"https://avatars.githubusercontent.com/u/12542084?v=3","gravatar_id":"","url":"https://api.github.com/users/proj4-bot","html_url":"https://github.com/proj4-bot","followers_url":"https://api.github.com/users/proj4-bot/followers","following_url":"https://api.github.com/users/proj4-bot/following{/other_user}","gists_url":"https://api.github.com/users/proj4-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/proj4-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/proj4-bot/subscriptions","organizations_url":"https://api.github.com/users/proj4-bot/orgs","repos_url":"https://api.github.com/users/proj4-bot/repos","events_url":"https://api.github.com/users/proj4-bot/events{/privacy}","received_events_url":"https://api.github.com/users/proj4-bot/received_events","type":"User","site_admin":false},"created_at":"2015-05-22T06:58:53Z","updated_at":"2015-05-22T06:58:53Z","body":"**Comment by warmerdam on 26 Jan 2009 16:54 UTC**\nI have restored these functions, but I do not really consider them part of the supported PROJ.4 API.  I think it would be most prudent for you to pull these into your application at some point.  \r\n\r\nAlternatively, if they have broad utility they should be documented more completely.  Possibly you would be interested in doing this? (man page and trac wiki for instance)\r\n\r\n\r\n"}}