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 --- src/pj_open_lib.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src') 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