diff options
| author | Thomas Knudsen <busstoptaktik@users.noreply.github.com> | 2018-02-07 12:15:04 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-07 12:15:04 +0100 |
| commit | 4f00f09f1c306e87dfea3a5bc49dcaae72280e00 (patch) | |
| tree | 8e1378ed32ac4f9b2badf37fd9b5ceac66d049c8 /src/proj.h | |
| parent | 4cd6fe1369f52bc53c8e595a218bd0e7426b05db (diff) | |
| download | PROJ-4f00f09f1c306e87dfea3a5bc49dcaae72280e00.tar.gz PROJ-4f00f09f1c306e87dfea3a5bc49dcaae72280e00.zip | |
Shrink PJ_XXX_INFO structs, but keep same syntax. (#775)
* Shrink PJ_XXX_INFO structs, but keep same syntax.
A number of the fixed length strings in the INFO structs are simply
reflections of material that already exists as static strings at a
number of places in the library (or in the case of PJ_INFO, really
*should* exist, and now is implemented).
This PR replaces these cases of constant length strings with const
char pointers. The usage syntax is unchanged, and so is the nice
property of having the return value allocated on the stack, and
hence not requiring explicit memory management by the caller.
proj_info now only does setup once - and the searchpath entry of
PJ_INFO is not arbitrarily truncated at 512 bytes. Repeated calls
simply returns a copy of already prepared material.
The id, description and definition entries of PJ_PROJ_INFO are now
also guaranteed to hold the entire text of the corresponding static
string, by being represented by a const char pointer to that actual
static string.
PJ_GRID_INFO and PJ_INIT_INFO (i.e. the two smallest INFO structs)
are unchanged.
* Eliminate pj_strlcpy - not needed anymore: Remining calls could
safely be replaced by strncpy.
* Extend PROJ_INFO with paths from pj_set_searchpath.
NOTE: Need to call pj_set_searchpath before first call to proj_info
Huge thanks to Kristian Evers and Even Rouault for comments, debugging and advice.
Diffstat (limited to 'src/proj.h')
| -rw-r--r-- | src/proj.h | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -239,20 +239,22 @@ union PJ_COORD { struct PJ_INFO { - char release[64]; /* Release info. Version + date */ - char version[64]; /* Full version number */ int major; /* Major release number */ int minor; /* Minor release number */ int patch; /* Patch level */ - char searchpath[512]; /* Paths where init and grid files are */ + const char *release; /* Release info. Version + date */ + const char *version; /* Full version number */ + const char *searchpath; /* Paths where init and grid files are */ /* looked for. Paths are separated by */ /* semi-colons. */ + const char * const *paths; + size_t path_count; }; struct PJ_PROJ_INFO { - char id[16]; /* Name of the projection in question */ - char description[128]; /* Description of the projection */ - char definition[512]; /* Projection definition */ + const char *id; /* Name of the projection in question */ + const char *description; /* Description of the projection */ + const char *definition; /* Projection definition */ int has_inverse; /* 1 if an inverse mapping exists, 0 otherwise */ double accuracy; /* Expected accuracy of the transformation. -1 if unknown. */ }; @@ -356,7 +358,7 @@ int proj_errno_restore (const PJ *P, int err); PJ_FACTORS proj_factors(PJ *P, LP lp); /* Info functions - get information about various PROJ.4 entities */ -PJ_INFO proj_info(void); +PJ_INFO proj_info(void); PJ_PROJ_INFO proj_pj_info(PJ *P); PJ_GRID_INFO proj_grid_info(const char *gridname); PJ_INIT_INFO proj_init_info(const char *initname); |
