pfree() after palloc() in trigger (was: Re: understanding Datum -> char * -> Datum conversions) - Mailing list pgsql-hackers

From Louis-David Mitterrand
Subject pfree() after palloc() in trigger (was: Re: understanding Datum -> char * -> Datum conversions)
Date
Msg-id 20000525144007.A11821@styx
Whole thread Raw
In response to Re: understanding Datum -> char * -> Datum conversions  (Louis-David Mitterrand <cunctator@apartia.ch>)
Responses Re: pfree() after palloc() in trigger (was: Re: understanding Datum -> char * -> Datum conversions)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Thu, May 25, 2000 at 01:25:19PM +0200, Louis-David Mitterrand wrote:
> On Thu, May 25, 2000 at 12:51:52PM +0200, Karel Zak wrote:
> > 
> >     float32  result = (float32) palloc(sizeof(float32data));

SHould I pfree(result) before the end of the trigger function?

> >     *result = 10.5;
> >     SPI_modifytuple(relation, tupdesc, &attnum, Float32GetDatum(result),
> >                                 NULL);

Instead of :
    float64 result = (float64) palloc(sizeof(float64data));SPI_modifytuple(relation, tupdesc,
&attnum,Float32GetDatum(result),NULL);

Can I do                                   double result = 10.5; /* for example */SPI_modifytuple(relation, tupdesc,
&attnum,Float32GetDatum(&result),NULL);                                                            ^^^
 

ie: pass the address of (regular double) "result" instead of using a
pointer;

-- 
Louis-David Mitterrand - ldm@apartia.org - http://www.apartia.fr

I don't build computers, I'm a cooling engineer.      -- Seymour Cray, founder of Cray Inc. 


pgsql-hackers by date:

Previous
From: Louis-David Mitterrand
Date:
Subject: Re: understanding Datum -> char * -> Datum conversions
Next
From: Chris Bitmead
Date:
Subject: gram.y PROBLEM with UNDER