aboutsummaryrefslogtreecommitdiff
path: root/src/projects.h
diff options
context:
space:
mode:
authorThomas Knudsen <thokn@sdfe.dk>2017-09-27 13:54:30 +0200
committerKristian Evers <kristianevers@gmail.com>2017-09-28 10:52:30 +0200
commitfa318ed5db0e00bf0a9fb3c18852efb44a095427 (patch)
tree8fbc595b7aa2019a40f4d1ea58dea47d81f5d775 /src/projects.h
parent6ea5a3cbe601bc14cb18614fdaa97092abf96f3c (diff)
downloadPROJ-fa318ed5db0e00bf0a9fb3c18852efb44a095427.tar.gz
PROJ-fa318ed5db0e00bf0a9fb3c18852efb44a095427.zip
Support a default destructor for PJ objects
Diffstat (limited to 'src/projects.h')
-rw-r--r--src/projects.h64
1 files changed, 5 insertions, 59 deletions
diff --git a/src/projects.h b/src/projects.h
index 872bf816..ece88cde 100644
--- a/src/projects.h
+++ b/src/projects.h
@@ -253,62 +253,8 @@ struct PJconsts {
void (*spc)(LP, PJ *, struct FACTORS *);
- void (*pfree)(PJ *);
-
- /*************************************************************************************
-
- E R R O R R E P O R T I N G
-
- **************************************************************************************
-
- Currently, we're doing error reporting through the context->last_errno indicator.
-
- It is, however, not entirely sure this will be the right way to do it in all
- cases: During allocation/initialization, it is certainly nice to have a higher
- level error indicator, since we primarily signal "something went wrong", by
- returning 0 from the pj_init family of functions - and with a null return we
- cannot pass messages through internal state in the PJ object.
-
- Historically, the errno variable has been used for that kind of messages, but
- apparently, thread safety was added to PROJ.4 at a time where it was not clear
- that errno is actually thread local.
-
- Additionally, errno semantics has historically been misinterpreted in parts of
- pj_init.c, a misinterpretation, that was mitigated by a hack in pj_malloc.c
- some 15 years ago.
-
- This PJ-local errno is a first step towards a more structured approach to
- error reporting, being implemented in the OBS_API (cf. pj_obs_api.[ch]), and
- related plumbing efforts.
-
- In due course this will let us get rid of the pj_malloc.c hack, and allow us
- to introduce a more layered error reporting structure, where errors are
- reported where they occur, and bubble up to the higher levels (context->errno,
- then thread local errno), so the highest level indicate "something went wrong
- somewhere", then the more localized ones can be used for pinpointing:
-
- errno: "something went wrong somewhere on this thread",
- context->last_errno: "something went wrong in some PROJ.4 related code",
- PJ->last_errno: "It was in THIS PJ something went wrong",
- pj_strerrno: "This was what went wrong".
-
- Which will be quite helpful, once fully implemented, especially for
- debugging complex transformation pipelines, while still maintaining backward
- compatibility in the messaging system.
-
- Note that there is even a global pj_errno, which is here and there accessed
- without acquiring lock. This, and the practise of resetting the thread local
- errno, should be given some consideration during the cleanup of the error
- reporting system.
-
- The name "last_errno", rather than "errno" is used partially for alignment
- with the context->last_errno, partially because in a multithreaded environment,
- errno is a macro, and spurious spaces turning "errno" into a separate token
- will expose it to macro expansion, to the tune of much confusion and agony.
-
- **************************************************************************************/
- int last_errno;
-
+ void *(*destructor)(PJ *, int);
+
/*************************************************************************************
@@ -616,7 +562,7 @@ C_NAMESPACE PJ *pj_##name (PJ *P) { \
P = (PJ*) pj_calloc (1, sizeof(PJ)); \
if (0==P) \
return 0; \
- P->pfree = freeup; \
+ P->destructor = pj_default_destructor; \
P->descr = des_##name; \
return P; \
} \
@@ -707,8 +653,6 @@ int pj_datum_set(projCtx,paralist *, PJ *);
int pj_prime_meridian_set(paralist *, PJ *);
int pj_angular_units_set(paralist *, PJ *);
-void pj_prepare (PJ *P, const char *description, void (*freeup)(struct PJconsts *), size_t sizeof_struct_opaque);
-
paralist *pj_clone_paralist( const paralist* );
paralist *pj_search_initcache( const char *filekey );
void pj_insert_initcache( const char *filekey, const paralist *list);
@@ -822,6 +766,8 @@ struct PJ_LIST *pj_get_list_ref( void );
struct PJ_SELFTEST_LIST *pj_get_selftest_list_ref ( void );
struct PJ_PRIME_MERIDIANS *pj_get_prime_meridians_ref( void );
+void *pj_default_destructor (PJ *P, int errlev);
+
double pj_atof( const char* nptr );
double pj_strtod( const char *nptr, char **endptr );
void pj_freeup_plain (PJ *P);