[Proj] pj_init - C programming question

Martin Thierer thierer at web.de
Thu May 19 10:00:20 EDT 2005

On Thursday 19 May 2005 15:39, Kevin S Lim wrote:


> Yes, the code that was listed _does_ work. =)  But it assumes that you know
> the projection parameter ahead of time and hence, can hard code them.
> My question revolves around the situations when you _do not_ know what is
> the projection and its parameters ahead of time.
> My approach would have been to dynamically allocate memory to char ** for
> an array of strings.
> But when you call sizeof(), it returns the number of bytes for the pointer
> and _not_ the sizeof() the array of string pointers.
> So essentially I'm trying to define the input and output projection and
> their parameters at run-time.
> I hope this provides more clarification.

Well, not really, as I understood all that, but not where your _exact_ problem 
is. But I'll try to answer anyway:

You have to do an two-stepped memory allocation. Something like (not tested):

parms_in=malloc((sizeof(char *)*cntParams)

Where cntParams is the number of parameters you want to have. 

Of course you also have to fill the parms_in[0..cntParams] with the actual 
parameter-strings. Then you pass parms_in to pj_init as in your code.

Did that help?



More information about the Proj mailing list