[Proj] BUG in pj_get_def

Frank Warmerdam warmerdam at pobox.com
Tue Sep 14 14:07:56 EDT 2004


Eric Miller wrote:
> It seems the utility function pj_get_def returns unused parameters.  The
> simple program below demonstrates.

Eric,

I have committed a slight variation on this and added a few comments to my
sparse code:

char *pj_get_def( PJ *P, int options )

{
     paralist *t;
     int l;
     char *definition;
     int  def_max = 10;

     definition = (char *) pj_malloc(def_max);
     definition[0] = '\0';

     for (t = P->params; t; t = t->next)
     {
         /* skip unused parameters ... mostly appended defaults and stuff */
         if (!t->used)
             continue;

         /* grow the resulting string if needed */
         l = strlen(t->param) + 1;
         if( strlen(definition) + l + 5 > def_max )
         {
             char *def2;

             def_max = def_max * 2 + l + 5;
             def2 = (char *) pj_malloc(def_max);
             strcpy( def2, definition );
             pj_dalloc( definition );
             definition = def2;
         }

         /* append this parameter */
         strcat( definition, " +" );
         strcat( definition, t->param );
     }

     return definition;
}

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the Proj mailing list