diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2008-04-18 18:43:09 +0000 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2008-04-18 18:43:09 +0000 |
commit | 7861d72ea204ef4085861f79f9c1749597160f72 (patch) | |
tree | d778614447739d8388ed9726b48422e623868571 /contrib/seg/seg.c | |
parent | b8e5581d762acceda22dd7347ed43d2e013a6df1 (diff) | |
download | postgresql-7861d72ea204ef4085861f79f9c1749597160f72.tar.gz postgresql-7861d72ea204ef4085861f79f9c1749597160f72.zip |
Modify the float4 datatype to be pass-by-val. Along the way, remove the last
uses of the long-deprecated float32 in contrib/seg; the definitions themselves
are still there, but no longer used. fmgr/README updated to match.
I added a CREATE FUNCTION to account for existing seg_center() code in seg.c
too, and some tests for it and the neighbor functions. At the same time,
remove checks for NULL which are not needed (because the functions are declared
STRICT).
I had to do some adjustments to contrib's btree_gist too. The choices for
representation there are not ideal for changing the underlying types :-(
Original patch by Zoltan Boszormenyi, with some adjustments by me.
Diffstat (limited to 'contrib/seg/seg.c')
-rw-r--r-- | contrib/seg/seg.c | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/contrib/seg/seg.c b/contrib/seg/seg.c index 65ddda1671f..9579eeab3ef 100644 --- a/contrib/seg/seg.c +++ b/contrib/seg/seg.c @@ -35,9 +35,9 @@ extern int seg_yydebug; */ SEG *seg_in(char *str); char *seg_out(SEG * seg); -float32 seg_lower(SEG * seg); -float32 seg_upper(SEG * seg); -float32 seg_center(SEG * seg); +float4 seg_lower(SEG * seg); +float4 seg_upper(SEG * seg); +float4 seg_center(SEG * seg); /* ** GiST support methods @@ -138,14 +138,14 @@ seg_out(SEG * seg) { if (seg->l_ext != '-') { - /* print the lower boudary if exists */ + /* print the lower boundary if exists */ p += restore(p, seg->lower, seg->l_sigd); p += sprintf(p, " "); } p += sprintf(p, ".."); if (seg->u_ext != '-') { - /* print the upper boudary if exists */ + /* print the upper boundary if exists */ p += sprintf(p, " "); if (seg->u_ext == '>' || seg->u_ext == '<' || seg->l_ext == '~') p += sprintf(p, "%c", seg->u_ext); @@ -156,40 +156,22 @@ seg_out(SEG * seg) return (result); } -float32 +float4 seg_center(SEG * seg) { - float32 result = (float32) palloc(sizeof(float32data)); - - if (!seg) - return (float32) NULL; - - *result = ((float) seg->lower + (float) seg->upper) / 2.0; - return (result); + return ((float) seg->lower + (float) seg->upper) / 2.0; } -float32 +float4 seg_lower(SEG * seg) { - float32 result = (float32) palloc(sizeof(float32data)); - - if (!seg) - return (float32) NULL; - - *result = (float) seg->lower; - return (result); + return seg->lower; } -float32 +float4 seg_upper(SEG * seg) { - float32 result = (float32) palloc(sizeof(float32data)); - - if (!seg) - return (float32) NULL; - - *result = (float) seg->upper; - return (result); + return seg->upper; } |