From 97313ea5ff14be6f771d38eb5b777eea76105541 Mon Sep 17 00:00:00 2001 From: Frank Warmerdam Date: Fri, 6 Jul 2007 14:58:03 +0000 Subject: improve searchpath clearning with pj_set_searchpath() git-svn-id: http://svn.osgeo.org/metacrs/proj/trunk@1400 4e78687f-474d-0410-85f9-8d5e500ac6b2 --- ChangeLog | 5 +++++ src/pj_open_lib.c | 19 +++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index a4c7c217..9db3184a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-07-06 Frank Warmerdam + + * src/pj_open_lib.c: Per suggestion from Janne, ensure + pj_set_searchpath(0,NULL) clears the search path cleanly. + 2007-06-04 Frank Warmerdam * src/proj.c: pj_free() the definition to simplify leak testing. diff --git a/src/pj_open_lib.c b/src/pj_open_lib.c index 1340654c..ffea6025 100644 --- a/src/pj_open_lib.c +++ b/src/pj_open_lib.c @@ -31,6 +31,9 @@ ****************************************************************************** * * $Log$ + * Revision 1.9 2007/07/06 14:58:03 fwarmerdam + * improve searchpath clearning with pj_set_searchpath() + * * Revision 1.8 2007/03/11 17:03:18 fwarmerdam * support drive letter prefixes on win32 and related fixes (bug 1499) * @@ -77,7 +80,8 @@ void pj_set_finder( const char *(*new_finder)(const char *) ) /* pj_set_searchpath() */ /* */ /* Path control for callers that can't practically provide */ -/* pj_set_finder() style callbacks. */ +/* pj_set_finder() style callbacks. Call with (0,NULL) as args */ +/* to clear the searchpath set. */ /************************************************************************/ void pj_set_searchpath ( int count, const char **path ) @@ -95,13 +99,16 @@ void pj_set_searchpath ( int count, const char **path ) search_path = NULL; } - search_path = pj_malloc(sizeof *search_path * count); - for (i = 0; i < count; i++) + if( count > 0 ) { - search_path[i] = pj_malloc(strlen(path[i]) + 1); - strcpy(search_path[i], path[i]); + search_path = pj_malloc(sizeof *search_path * count); + for (i = 0; i < count; i++) + { + search_path[i] = pj_malloc(strlen(path[i]) + 1); + strcpy(search_path[i], path[i]); + } } - + path_count = count; } -- cgit v1.2.3