Re: [GENERAL] Problem with C functions ?

selkovjr@mcs.anl.gov

From: "Gene Selkov, Jr." <selkovjr@mcs.anl.gov>
To: Manuel Weindorf <weindorf@ipf.uni-karlsruhe.de>, pgsql-general@postgreSQL.org
Date: 1999-11-14T04:56:25Z
Lists: pgsql-general
[having found this topic irrelevant to INTERFACES, I'm not posting my reply there]

> Hi there,
> 
> I compiled a C-funtion to compute the azimuth of a LSEG but the function
> never
> returns the correct value

>   double ori;
> ....
>   return( ori );  
> 

The right way to do it would be:
	
#include "postgres.h"
#include "utils/palloc.h"

	float64 ori = (float64) palloc(sizeof(float64data));

	*ori = (float64) .... /* double type expression */

	return ( ori );
}


--Gene