diff options
| author | Kristian Evers <kristianevers@gmail.com> | 2020-11-26 20:58:01 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-26 20:58:01 +0100 |
| commit | 3cb26a406a7e1a964f5f3b5caf3c624222664fb2 (patch) | |
| tree | 414dad90bd94170f6e619197b9a47bfca096d322 /src/init.cpp | |
| parent | f5b3616bb03f8e52a5e5a23704d645492a662393 (diff) | |
| parent | d9205b9245388f23b65917a21ec72d6bec15d035 (diff) | |
| download | PROJ-3cb26a406a7e1a964f5f3b5caf3c624222664fb2.tar.gz PROJ-3cb26a406a7e1a964f5f3b5caf3c624222664fb2.zip | |
Merge pull request #2403 from kbevers/remove-proj_api.h
Remove proj_api.h
Diffstat (limited to 'src/init.cpp')
| -rw-r--r-- | src/init.cpp | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/src/init.cpp b/src/init.cpp index 101fc8ad..7b614c5f 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1,7 +1,7 @@ /****************************************************************************** * Project: PROJ.4 * Purpose: Initialize projection object from string definition. Includes - * pj_init(), pj_init_plus() and pj_free() function. + * pj_init(), and pj_init_plus() function. * Author: Gerald Evenden, Frank Warmerdam <warmerdam@pobox.com> * ****************************************************************************** @@ -55,7 +55,7 @@ static paralist *string_to_paralist (PJ_CONTEXT *ctx, char *definition) { /* Keep a handle to the start of the list, so we have something to return */ auto param = pj_mkparam_ws (c, &c); if (nullptr==param) { - pj_dealloc_params (ctx, first, ENOMEM); + free_params (ctx, first, ENOMEM); return nullptr; } if (nullptr==last) { @@ -84,7 +84,7 @@ static char *get_init_string (PJ_CONTEXT *ctx, const char *name) { char *buffer = nullptr; size_t n; - fname = static_cast<char*>(pj_malloc (MAX_PATH_FILENAME+ID_TAG_MAX+3)); + fname = static_cast<char*>(malloc (MAX_PATH_FILENAME+ID_TAG_MAX+3)); if (nullptr==fname) { return nullptr; } @@ -96,7 +96,7 @@ static char *get_init_string (PJ_CONTEXT *ctx, const char *name) { else key += 5; if (MAX_PATH_FILENAME + ID_TAG_MAX + 2 < strlen (key)) { - pj_dealloc (fname); + free (fname); return nullptr; } memmove (fname, key, strlen (key) + 1); @@ -105,7 +105,7 @@ static char *get_init_string (PJ_CONTEXT *ctx, const char *name) { section = strrchr(fname, ':'); if (nullptr==section) { proj_context_errno_set (ctx, PJD_ERR_NO_COLON_IN_INIT_STRING); - pj_dealloc (fname); + free (fname); return nullptr; } *section = 0; @@ -117,7 +117,7 @@ static char *get_init_string (PJ_CONTEXT *ctx, const char *name) { auto file = NS_PROJ::FileManager::open_resource_file(ctx, fname); if (nullptr==file) { - pj_dealloc (fname); + free (fname); proj_context_errno_set (ctx, PJD_ERR_NO_OPTION_IN_INIT_FILE); return nullptr; } @@ -131,7 +131,7 @@ static char *get_init_string (PJ_CONTEXT *ctx, const char *name) { line = file->read_line(MAX_LINE_LENGTH, maxLenReached, eofReached); /* End of file? */ if (maxLenReached || eofReached) { - pj_dealloc (fname); + free (fname); proj_context_errno_set (ctx, PJD_ERR_NO_OPTION_IN_INIT_FILE); return nullptr; } @@ -149,9 +149,9 @@ static char *get_init_string (PJ_CONTEXT *ctx, const char *name) { } /* We're at the first line of the right section - copy line to buffer */ - buffer = static_cast<char*>(pj_malloc (current_buffer_size)); + buffer = static_cast<char*>(malloc (current_buffer_size)); if (nullptr==buffer) { - pj_dealloc (fname); + free (fname); return nullptr; } @@ -183,22 +183,22 @@ static char *get_init_string (PJ_CONTEXT *ctx, const char *name) { pj_chomp (&line[0]); /* Remove '#' style comments */ next_length = strlen (line.data()) + buffer_length + 2; if (next_length > current_buffer_size) { - char *b = static_cast<char*>(pj_malloc (2 * current_buffer_size)); + char *b = static_cast<char*>(malloc (2 * current_buffer_size)); if (nullptr==b) { - pj_dealloc (buffer); + free (buffer); buffer = nullptr; break; } strcpy (b, buffer); current_buffer_size *= 2; - pj_dealloc (buffer); + free (buffer); buffer = b; } buffer[buffer_length] = ' '; strcpy (buffer + buffer_length + 1, line.data()); } - pj_dealloc (fname); + free (fname); if (nullptr==buffer) return nullptr; pj_shrink (buffer); @@ -257,7 +257,7 @@ Expand key from buffer or (if not in buffer) from init file PJ* src; const char* proj_string; - pj_ctx_set_errno( ctx, 0 ); + proj_context_errno_set( ctx, 0 ); if( !allow_init_epsg ) { pj_log (ctx, PJ_LOG_TRACE, "%s expansion disallowed", xkey); @@ -306,7 +306,7 @@ Expand key from buffer or (if not in buffer) from init file definition, init_items->param, init_items->next ? init_items->next->param : "(empty)"); - pj_dealloc (definition); + free (definition); if (nullptr==init_items) return nullptr; @@ -415,7 +415,7 @@ pj_init_plus( const char *definition ) } PJ * -pj_init_plus_ctx( projCtx ctx, const char *definition ) +pj_init_plus_ctx( PJ_CONTEXT *ctx, const char *definition ) { #define MAX_ARG 200 char *argv[MAX_ARG]; @@ -424,7 +424,7 @@ pj_init_plus_ctx( projCtx ctx, const char *definition ) PJ *result = nullptr; /* make a copy that we can manipulate */ - defn_copy = (char *) pj_malloc( strlen(definition)+1 ); + defn_copy = (char *) malloc( strlen(definition)+1 ); if (!defn_copy) return nullptr; strcpy( defn_copy, definition ); @@ -447,8 +447,8 @@ pj_init_plus_ctx( projCtx ctx, const char *definition ) if( argc+1 == MAX_ARG ) { - pj_dalloc( defn_copy ); - pj_ctx_set_errno( ctx, PJD_ERR_UNPARSEABLE_CS_DEF ); + free( defn_copy ); + proj_context_errno_set( ctx, PJD_ERR_UNPARSEABLE_CS_DEF ); return nullptr; } @@ -477,7 +477,7 @@ pj_init_plus_ctx( projCtx ctx, const char *definition ) /* perform actual initialization */ result = pj_init_ctx( ctx, argc, argv ); - pj_dalloc( defn_copy ); + free( defn_copy ); return result; } @@ -511,7 +511,7 @@ static PJ_CONSTRUCTOR locate_constructor (const char *name) { PJ * -pj_init_ctx(projCtx ctx, int argc, char **argv) { +pj_init_ctx(PJ_CONTEXT *ctx, int argc, char **argv) { /* Legacy interface: allow init=epsg:XXXX syntax by default */ int allow_init_epsg = proj_context_get_use_proj4_init_rules(ctx, TRUE); return pj_init_ctx_with_allow_init_epsg(ctx, argc, argv, allow_init_epsg); @@ -519,7 +519,7 @@ pj_init_ctx(projCtx ctx, int argc, char **argv) { PJ * -pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_init_epsg) { +pj_init_ctx_with_allow_init_epsg(PJ_CONTEXT *ctx, int argc, char **argv, int allow_init_epsg) { const char *s; char *name; PJ_CONSTRUCTOR proj; @@ -538,7 +538,7 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i ctx->last_errno = 0; if (argc <= 0) { - pj_ctx_set_errno (ctx, PJD_ERR_NO_ARGS); + proj_context_errno_set (ctx, PJD_ERR_NO_ARGS); return nullptr; } @@ -552,13 +552,13 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i /* can't have nested pipelines directly */ if (n_pipelines > 1) { - pj_ctx_set_errno (ctx, PJD_ERR_MALFORMED_PIPELINE); + proj_context_errno_set (ctx, PJD_ERR_MALFORMED_PIPELINE); return nullptr; } /* don't allow more than one +init in non-pipeline operations */ if (n_pipelines == 0 && n_inits > 1) { - pj_ctx_set_errno (ctx, PJD_ERR_TOO_MANY_INITS); + proj_context_errno_set (ctx, PJD_ERR_TOO_MANY_INITS); return nullptr; } @@ -566,14 +566,14 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i /* put arguments into internal linked list */ start = curr = pj_mkparam(argv[0]); if (!curr) { - pj_dealloc_params (ctx, start, ENOMEM); + free_params (ctx, start, ENOMEM); return nullptr; } for (i = 1; i < argc; ++i) { curr->next = pj_mkparam(argv[i]); if (!curr->next) { - pj_dealloc_params (ctx, start, ENOMEM); + free_params (ctx, start, ENOMEM); return nullptr; } curr = curr->next; @@ -588,31 +588,31 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i if (init && n_pipelines == 0) { init = pj_expand_init_internal (ctx, init, allow_init_epsg); if (!init) { - pj_dealloc_params (ctx, start, PJD_ERR_NO_ARGS); + free_params (ctx, start, PJD_ERR_NO_ARGS); return nullptr; } } if (ctx->last_errno) { - pj_dealloc_params (ctx, start, ctx->last_errno); + free_params (ctx, start, ctx->last_errno); return nullptr; } /* Find projection selection */ curr = pj_param_exists (start, "proj"); if (nullptr==curr) { - pj_dealloc_params (ctx, start, PJD_ERR_PROJ_NOT_NAMED); + free_params (ctx, start, PJD_ERR_PROJ_NOT_NAMED); return nullptr; } name = curr->param; if (strlen (name) < 6) { - pj_dealloc_params (ctx, start, PJD_ERR_PROJ_NOT_NAMED); + free_params (ctx, start, PJD_ERR_PROJ_NOT_NAMED); return nullptr; } name += 5; proj = locate_constructor (name); if (nullptr==proj) { - pj_dealloc_params (ctx, start, PJD_ERR_UNKNOWN_PROJECTION_ID); + free_params (ctx, start, PJD_ERR_UNKNOWN_PROJECTION_ID); return nullptr; } @@ -621,7 +621,7 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i /* Allocate projection structure */ PIN = proj(nullptr); if (nullptr==PIN) { - pj_dealloc_params (ctx, start, ENOMEM); + free_params (ctx, start, ENOMEM); return nullptr; } @@ -820,7 +820,7 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i PIN->from_greenwich = 0.0; /* Private object for the geodesic functions */ - PIN->geod = static_cast<struct geod_geodesic*>(pj_calloc (1, sizeof (struct geod_geodesic))); + PIN->geod = static_cast<struct geod_geodesic*>(calloc (1, sizeof (struct geod_geodesic))); if (nullptr==PIN->geod) return pj_default_destructor (PIN, ENOMEM); geod_init(PIN->geod, PIN->a, (1 - sqrt (1 - PIN->es))); @@ -829,7 +829,7 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i err = proj_errno_reset (PIN); PIN = proj(PIN); if (proj_errno (PIN)) { - pj_free(PIN); + proj_destroy(PIN); return nullptr; } proj_errno_restore (PIN, err); |
