Re: [GENERAL] Problem with C functions ? - Mailing list pgsql-general

From Gene Selkov, Jr.
Subject Re: [GENERAL] Problem with C functions ?
Date
Msg-id 199911140456.WAA13708@antares
Whole thread Raw
In response to Problem with C functions ?  (Manuel Weindorf <weindorf@ipf.uni-karlsruhe.de>)
List 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

pgsql-general by date:

Previous
From: Larry Rosenman
Date:
Subject: [ADMIN] 6.5.3/doesn't recognize localhost in pg_hba.conf (fwd)
Next
From: "Gene Selkov, Jr."
Date:
Subject: Re: [GENERAL] does GIS DMS data type already exist?