]> granicus.if.org Git - postgresql/commitdiff
Cleanup of GiST extensions in contrib/: now that we always invoke GiST
authorNeil Conway <neilc@samurai.com>
Sat, 21 May 2005 12:08:06 +0000 (12:08 +0000)
committerNeil Conway <neilc@samurai.com>
Sat, 21 May 2005 12:08:06 +0000 (12:08 +0000)
methods in a short-lived memory context, there is no need for GiST methods
to do their own manual (and error-prone) memory management.

16 files changed:
contrib/btree_gist/btree_bit.c
contrib/btree_gist/btree_bytea.c
contrib/btree_gist/btree_numeric.c
contrib/btree_gist/btree_text.c
contrib/btree_gist/btree_time.c
contrib/btree_gist/btree_ts.c
contrib/btree_gist/btree_utils_num.c
contrib/btree_gist/btree_utils_var.c
contrib/cube/cube.c
contrib/ltree/_ltree_gist.c
contrib/ltree/ltree_gist.c
contrib/pg_trgm/trgm_gist.c
contrib/rtree_gist/rtree_gist.c
contrib/seg/seg.c
contrib/tsearch/gistidx.c
contrib/tsearch2/gistidx.c

index 0cdd277a123d689a31273c991c5677bc0042c458..0c7108bc60065ab10c1466dc4c4be8fa74483d6b 100644 (file)
@@ -127,7 +127,6 @@ gbt_bit_consistent(PG_FUNCTION_ARGS)
 {
        GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
        GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
-       void       *qtst = (void *) PG_GETARG_POINTER(1);
        void       *query = (void *) DatumGetByteaP(PG_GETARG_DATUM(1));
        StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
        bool            retval = FALSE;
@@ -140,11 +139,7 @@ gbt_bit_consistent(PG_FUNCTION_ARGS)
                bytea      *q = gbt_bit_xfrm((bytea *) query);
 
                retval = gbt_var_consistent(&r, (void *) q, &strategy, FALSE, &tinfo);
-               pfree(q);
        }
-
-       if (qtst != query)
-               pfree(query);
        PG_RETURN_BOOL(retval);
 }
 
index 79095fc0e9da1a2147a8f3f83d24463466b4ecf1..375cc26cc6cd46e17709822c176bc102833c3f90 100644 (file)
@@ -97,16 +97,12 @@ gbt_bytea_consistent(PG_FUNCTION_ARGS)
 {
        GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
        GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
-       void       *qtst = (void *) PG_GETARG_POINTER(1);
        void       *query = (void *) DatumGetByteaP(PG_GETARG_DATUM(1));
        StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
-       bool            retval = FALSE;
+       bool            retval;
        GBT_VARKEY_R r = gbt_var_key_readable(key);
 
        retval = gbt_var_consistent(&r, query, &strategy, GIST_LEAF(entry), &tinfo);
-
-       if (qtst != query)
-               pfree(query);
        PG_RETURN_BOOL(retval);
 }
 
index d9c3184fe6dfffaee335a0a34b1f5ad6f8960405..fcfd4613ef170f6488353aab14c14f9de1468ff0 100644 (file)
@@ -98,16 +98,12 @@ gbt_numeric_consistent(PG_FUNCTION_ARGS)
 
        GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
        GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
-       void       *qtst = (void *) PG_GETARG_POINTER(1);
        void       *query = (void *) DatumGetNumeric(PG_GETARG_DATUM(1));
        StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
-       bool            retval = FALSE;
+       bool            retval;
        GBT_VARKEY_R r = gbt_var_key_readable(key);
 
        retval = gbt_var_consistent(&r, query, &strategy, GIST_LEAF(entry), &tinfo);
-
-       if (qtst != query)
-               pfree(query);
        PG_RETURN_BOOL(retval);
 }
 
@@ -164,8 +160,6 @@ gbt_numeric_penalty(PG_FUNCTION_ARGS)
                                                                                         PointerGetDatum(uk.lower)
                                                                                         ));
 
-       pfree(DatumGetPointer(uni));
-
        os = DatumGetNumeric(DirectFunctionCall2(
                                                                                         numeric_sub,
                                                                                         PointerGetDatum(ok.upper),
@@ -178,27 +172,21 @@ gbt_numeric_penalty(PG_FUNCTION_ARGS)
                                                                                         NumericGetDatum(os)
                                                                                         ));
 
-       pfree(os);
-
        if (NUMERIC_IS_NAN(us))
        {
-
                if (NUMERIC_IS_NAN(os))
                        *result = 0.0;
                else
                        *result = 1.0;
-
        }
        else
        {
-
                Numeric         nul = DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(0)));
 
                *result = 0.0;
 
                if (DirectFunctionCall2(numeric_gt, NumericGetDatum(ds), NumericGetDatum(nul)))
                {
-
                        *result += FLT_MIN;
                        os = DatumGetNumeric(DirectFunctionCall2(
                                                                                                         numeric_div,
@@ -206,19 +194,12 @@ gbt_numeric_penalty(PG_FUNCTION_ARGS)
                                                                                                         NumericGetDatum(us)
                                                                                                         ));
                        *result += (float4) DatumGetFloat8(DirectFunctionCall1(numeric_float8_no_overflow, NumericGetDatum(os)));
-                       pfree(os);
-
                }
-
-               pfree(nul);
        }
 
        if (*result > 0)
                *result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1));
 
-       pfree(us);
-       pfree(ds);
-
        PG_RETURN_POINTER(result);
 }
 
index 50b81ab045436b27a1b5bbd5eb9a910909394eb5..d81e7d0fd92ef51723107b2c9748e9599444d880 100644 (file)
@@ -108,8 +108,6 @@ gbt_bpchar_compress(PG_FUNCTION_ARGS)
                                          entry->rel, entry->page,
                                          entry->offset, VARSIZE(DatumGetPointer(d)), TRUE);
                retval = gbt_var_compress(&trim, &tinfo);
-
-               pfree(DatumGetPointer(d));
        }
        else
                retval = entry;
@@ -124,7 +122,6 @@ gbt_text_consistent(PG_FUNCTION_ARGS)
 {
        GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
        GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
-       void       *qtst = (void *) PG_GETARG_POINTER(1);
        void       *query = (void *) DatumGetTextP(PG_GETARG_DATUM(1));
        StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
        bool            retval = FALSE;
@@ -132,9 +129,6 @@ gbt_text_consistent(PG_FUNCTION_ARGS)
 
        retval = gbt_var_consistent(&r, query, &strategy, GIST_LEAF(entry), &tinfo);
 
-       if (qtst != query)
-               pfree(query);
-
        PG_RETURN_BOOL(retval);
 }
 
@@ -144,25 +138,17 @@ gbt_bpchar_consistent(PG_FUNCTION_ARGS)
 {
        GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
        GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
-       void       *qtst = (void *) PG_GETARG_POINTER(1);
        void       *query = (void *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(1)));
        void       *trim = (void *) DatumGetPointer(DirectFunctionCall1(rtrim1, PointerGetDatum(query)));
        StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
-       bool            retval = FALSE;
+       bool            retval;
        GBT_VARKEY_R r = gbt_var_key_readable(key);
 
        retval = gbt_var_consistent(&r, trim, &strategy, GIST_LEAF(entry), &tinfo);
-
-       pfree(trim);
-
-       if (qtst != query)
-               pfree(query);
        PG_RETURN_BOOL(retval);
 }
 
 
-
-
 Datum
 gbt_text_union(PG_FUNCTION_ARGS)
 {
index c55385ea82d274ef3c16d938abdfdc6f766cdaae..491d05b631f0fb164f71c37161c907392110776c 100644 (file)
@@ -222,7 +222,6 @@ gbt_time_penalty(PG_FUNCTION_ARGS)
 
        /* see interval_larger */
        res = Max(intr->time + intr->month * (30 * 86400), 0);
-       pfree(intr);
 
        intr = DatumGetIntervalP(DirectFunctionCall2(
                                                                                                 time_mi_time,
@@ -231,7 +230,6 @@ gbt_time_penalty(PG_FUNCTION_ARGS)
 
        /* see interval_larger */
        res += Max(intr->time + intr->month * (30 * 86400), 0);
-       pfree(intr);
 
        *result = 0.0;
 
@@ -244,7 +242,6 @@ gbt_time_penalty(PG_FUNCTION_ARGS)
                *result += FLT_MIN;
                *result += (float) (res / ((double) (res + intr->time + intr->month * (30 * 86400))));
                *result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1));
-               pfree(intr);
        }
 
        PG_RETURN_POINTER(result);
index aaa0c2e5a4bfb63715e7de42901298eb254f44f1..3d5defe3db07a29bc214c58c99c7d57814cb34c7 100644 (file)
@@ -226,7 +226,6 @@ gbt_ts_penalty(PG_FUNCTION_ARGS)
 
 #ifdef HAVE_INT64_TIMESTAMP
        int64           res;
-
 #else
        double          res;
 #endif
@@ -240,7 +239,6 @@ gbt_ts_penalty(PG_FUNCTION_ARGS)
        /* see interval_larger */
 
        res = Max(intr->time + intr->month * (30 * 86400), 0);
-       pfree(intr);
 
        intr = DatumGetIntervalP(DirectFunctionCall2(
                                                                                                 timestamp_mi,
@@ -250,7 +248,6 @@ gbt_ts_penalty(PG_FUNCTION_ARGS)
 
        /* see interval_larger */
        res += Max(intr->time + intr->month * (30 * 86400), 0);
-       pfree(intr);
 
        *result = 0.0;
 
@@ -264,11 +261,9 @@ gbt_ts_penalty(PG_FUNCTION_ARGS)
                *result += FLT_MIN;
                *result += (float) (res / ((double) (res + intr->time + intr->month * (30 * 86400))));
                *result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1));
-               pfree(intr);
        }
 
        PG_RETURN_POINTER(result);
-
 }
 
 
index ab4355e6fe8300fb5e5b1dd84f3faa6eeefc10ff..69292758f58394d3ae04416f6d5d109f92dd14fe 100644 (file)
@@ -246,7 +246,5 @@ gbt_num_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v,
                }
        }
 
-       pfree(arr);
-
        return v;
 }
index d751a11f0ebddd72ed349fe9f6cc1f212f716571..720381428f2e980f81f6e8b297dde7c3ba3f189c 100644 (file)
@@ -9,21 +9,21 @@ Datum           gbt_var_decompress(PG_FUNCTION_ARGS);
 Datum
 gbt_var_decompress(PG_FUNCTION_ARGS)
 {
-        GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
-        GBT_VARKEY   *key = (GBT_VARKEY *) DatumGetPointer(PG_DETOAST_DATUM(entry->key));
+       GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
+       GBT_VARKEY   *key = (GBT_VARKEY *) DatumGetPointer(PG_DETOAST_DATUM(entry->key));
 
-        if (key != (GBT_VARKEY *) DatumGetPointer(entry->key))
-        {
-                GISTENTRY  *retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
+       if (key != (GBT_VARKEY *) DatumGetPointer(entry->key))
+       {
+               GISTENTRY  *retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
 
-                gistentryinit(*retval, PointerGetDatum(key),
-                                          entry->rel, entry->page,
-                                          entry->offset, VARSIZE(key), FALSE);
+               gistentryinit(*retval, PointerGetDatum(key),
+                                         entry->rel, entry->page,
+                                         entry->offset, VARSIZE(key), FALSE);
 
-                PG_RETURN_POINTER(retval);
-        }
+               PG_RETURN_POINTER(retval);
+       }
 
-        PG_RETURN_POINTER(entry);
+       PG_RETURN_POINTER(entry);
 }
 
 /* Returns a better readable representaion of variable key ( sets pointer ) */
@@ -216,7 +216,6 @@ gbt_var_bin_union(Datum *u, GBT_VARKEY * e, const gbtree_vinfo * tinfo)
        GBT_VARKEY_R nr;
        GBT_VARKEY_R eo = gbt_var_key_readable(e);
 
-
        if (eo.lower == eo.upper)       /* leaf */
        {
                tmp = gbt_var_leaf2node(e, tinfo);
@@ -235,20 +234,16 @@ gbt_var_bin_union(Datum *u, GBT_VARKEY * e, const gbtree_vinfo * tinfo)
                        nr.upper = ro.upper;
                        nk = gbt_var_key_copy(&nr, TRUE);
                }
+
                if ((*tinfo->f_cmp) ((bytea *) ro.upper, (bytea *) eo.upper) < 0)
                {
                        nr.upper = eo.upper;
                        nr.lower = ro.lower;
                        nk = gbt_var_key_copy(&nr, TRUE);
                }
+
                if (nk)
-               {
-                       pfree(DatumGetPointer(*u));
                        *u = PointerGetDatum(nk);
-               }
-
-
-
        }
        else
        {
@@ -256,10 +251,6 @@ gbt_var_bin_union(Datum *u, GBT_VARKEY * e, const gbtree_vinfo * tinfo)
                nr.upper = eo.upper;
                *u = PointerGetDatum(gbt_var_key_copy(&nr, TRUE));
        }
-
-       if (tmp && tmp != e)
-               pfree(tmp);
-
 }
 
 
@@ -273,15 +264,12 @@ gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo * tinfo)
        if (entry->leafkey)
        {
                GBT_VARKEY *r = NULL;
-               bytea      *tstd = (bytea *) DatumGetPointer(entry->key);               /* toasted       */
-               bytea      *leaf = (bytea *) DatumGetPointer(PG_DETOAST_DATUM(entry->key));             /* untoasted */
+               bytea      *leaf = (bytea *) DatumGetPointer(PG_DETOAST_DATUM(entry->key));
                GBT_VARKEY_R u;
 
                u.lower = u.upper = leaf;
                r = gbt_var_key_copy(&u, FALSE);
 
-               if (tstd != leaf)
-                       pfree(leaf);
                retval = palloc(sizeof(GISTENTRY));
                gistentryinit(*retval, PointerGetDatum(r),
                                          entry->rel, entry->page,
@@ -319,7 +307,6 @@ gbt_var_union(const GistEntryVector *entryvec, int32 *size, const gbtree_vinfo *
 
 
        /* Truncate (=compress) key */
-
        if (tinfo->trnc)
        {
                int32           plen;
@@ -328,7 +315,6 @@ gbt_var_union(const GistEntryVector *entryvec, int32 *size, const gbtree_vinfo *
                plen = gbt_var_node_cp_len((GBT_VARKEY *) DatumGetPointer(out), tinfo);
                trc = gbt_var_node_truncate((GBT_VARKEY *) DatumGetPointer(out), plen + 1, tinfo);
 
-               pfree(DatumGetPointer(out));
                out = PointerGetDatum(trc);
        }
 
@@ -428,17 +414,12 @@ gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n, const gbtree
                        }
                        dres /= 256.0;
                }
-               pfree(DatumGetPointer(d));
 
                *res += FLT_MIN;
                *res += (float) (dres / ((double) (ol + 1)));
                *res *= (FLT_MAX / (o->rel->rd_att->natts + 1));
-
        }
 
-       if (tmp && tmp != newe)
-               pfree(tmp);
-
        return res;
 }
 
@@ -524,18 +505,9 @@ gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v, const gbtre
                }
        }
 
-       /* Free strxfrm'ed leafs */
-       for (i = 0; i < svcntr; i++)
-               pfree(sv[i]);
-
-       if (sv)
-               pfree(sv);
-
        /* Truncate (=compress) key */
-
        if (tinfo->trnc)
        {
-
                int32           ll = gbt_var_node_cp_len((GBT_VARKEY *) DatumGetPointer(v->spl_ldatum), tinfo);
                int32           lr = gbt_var_node_cp_len((GBT_VARKEY *) DatumGetPointer(v->spl_rdatum), tinfo);
                GBT_VARKEY *dl;
@@ -546,15 +518,10 @@ gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v, const gbtre
 
                dl = gbt_var_node_truncate((GBT_VARKEY *) DatumGetPointer(v->spl_ldatum), ll, tinfo);
                dr = gbt_var_node_truncate((GBT_VARKEY *) DatumGetPointer(v->spl_rdatum), ll, tinfo);
-               pfree(DatumGetPointer(v->spl_ldatum));
-               pfree(DatumGetPointer(v->spl_rdatum));
                v->spl_ldatum = PointerGetDatum(dl);
                v->spl_rdatum = PointerGetDatum(dr);
-
        }
 
-       pfree(arr);
-
        return v;
 }
 
index 658536ac4d62c9e2a12b3765cc7a251e4bc23003..fd0609ee26b7588ed1b8bc1ef33dbcd6f7b3a5e9 100644 (file)
@@ -229,8 +229,6 @@ g_cube_union(GistEntryVector *entryvec, int *sizep)
                out = g_cube_binary_union(tmp, (NDBOX *)
                                                                DatumGetPointer(entryvec->vector[i].key),
                                                                  sizep);
-               if (i > 1)
-                       pfree(tmp);
                tmp = out;
        }
 
@@ -269,7 +267,6 @@ g_cube_penalty(GISTENTRY *origentry, GISTENTRY *newentry, float *result)
        rt_cube_size(ud, &tmp1);
        rt_cube_size((NDBOX *) DatumGetPointer(origentry->key), &tmp2);
        *result = (float) (tmp1 - tmp2);
-       pfree(ud);
 
        /*
         * fprintf(stderr, "penalty\n"); fprintf(stderr, "\t%g\n", *result);
@@ -339,11 +336,6 @@ g_cube_picksplit(GistEntryVector *entryvec,
                        rt_cube_size(inter_d, &size_inter);
                        size_waste = size_union - size_inter;
 
-                       pfree(union_d);
-
-                       if (inter_d != (NDBOX *) NULL)
-                               pfree(inter_d);
-
                        /*
                         * are these a more promising split than what we've already
                         * seen?
@@ -415,8 +407,6 @@ g_cube_picksplit(GistEntryVector *entryvec,
                /* pick which page to add it to */
                if (size_alpha - size_l < size_beta - size_r)
                {
-                       pfree(datum_l);
-                       pfree(union_dr);
                        datum_l = union_dl;
                        size_l = size_alpha;
                        *left++ = i;
@@ -424,8 +414,6 @@ g_cube_picksplit(GistEntryVector *entryvec,
                }
                else
                {
-                       pfree(datum_r);
-                       pfree(union_dl);
                        datum_r = union_dr;
                        size_r = size_alpha;
                        *right++ = i;
index 50a38405c675d71ee3a16359afcc78b2a08fdafb..f68e9902b52c0d485cd48a0a2e1e8eac90624ef0 100644 (file)
@@ -90,9 +90,6 @@ _ltree_compress(PG_FUNCTION_ARGS)
                        item = NEXTVAL(item);
                }
 
-               if (PointerGetDatum(val) != entry->key)
-                       pfree(val);
-
                retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
                gistentryinit(*retval, PointerGetDatum(key),
                                          entry->rel, entry->page,
@@ -424,7 +421,6 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
        }
 
        *right = *left = FirstOffsetNumber;
-       pfree(costvector);
 
        v->spl_ldatum = PointerGetDatum(datum_l);
        v->spl_rdatum = PointerGetDatum(datum_r);
index ec81ce1c1835af66f544b3305bfbf1d5246ae7c1..693244d9daed9d6d963e6ded319fdc2cbb177031 100644 (file)
@@ -77,9 +77,6 @@ ltree_compress(PG_FUNCTION_ARGS)
                key->flag = LTG_ONENODE;
                memcpy((void *) LTG_NODE(key), (void *) val, val->len);
 
-               if (PointerGetDatum(val) != entry->key)
-                       pfree(val);
-
                retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
                gistentryinit(*retval, PointerGetDatum(key),
                                          entry->rel, entry->page,
@@ -432,7 +429,6 @@ ltree_picksplit(PG_FUNCTION_ARGS)
        else
                memcpy((void *) LTG_RNODE(ru), (void *) ru_r, ru_r->len);
 
-       pfree(array);
        v->spl_ldatum = PointerGetDatum(lu);
        v->spl_rdatum = PointerGetDatum(ru);
 
index 3ae8f4b3aa285d70f48c3a60e7708dee93646866..33ed6d5e1f0e1c4aec4b5307e8063c8836497c09 100644 (file)
@@ -91,13 +91,9 @@ gtrgm_compress(PG_FUNCTION_ARGS)
        if (entry->leafkey)
        {                                                       /* trgm */
                TRGM       *res;
-               text       *toastedval = (text *) DatumGetPointer(entry->key);
                text       *val = (text *) DatumGetPointer(PG_DETOAST_DATUM(entry->key));
 
                res = generate_trgm(VARDATA(val), VARSIZE(val) - VARHDRSZ);
-               if (val != toastedval)
-                       pfree(val);
-
                retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
                gistentryinit(*retval, PointerGetDatum(res),
                                          entry->rel, entry->page,
@@ -175,9 +171,6 @@ gtrgm_consistent(PG_FUNCTION_ARGS)
 #endif
        }
 
-       PG_FREE_IF_COPY(query, 1);
-       pfree(qtrg);
-
        PG_RETURN_BOOL(res);
 }
 
@@ -603,8 +596,6 @@ gtrgm_picksplit(PG_FUNCTION_ARGS)
        }
 
        *right = *left = FirstOffsetNumber;
-       pfree(costvector);
-       pfree(cache);
        v->spl_ldatum = PointerGetDatum(datum_l);
        v->spl_rdatum = PointerGetDatum(datum_r);
 
index 92714522d8013abd7d75c33c99b49e143cd833b3..d2f41569200927bdad1c8531790bd3772309dd6b 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *     $PostgreSQL: pgsql/contrib/rtree_gist/rtree_gist.c,v 1.10 2004/08/29 05:06:37 momjian Exp $
+ *     $PostgreSQL: pgsql/contrib/rtree_gist/rtree_gist.c,v 1.11 2005/05/21 12:08:05 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -152,9 +152,6 @@ gbox_penalty(PG_FUNCTION_ARGS)
 
        ud = DirectFunctionCall2(rt_box_union, origentry->key, newentry->key);
        tmp1 = size_box(ud);
-       if (DatumGetPointer(ud) != NULL)
-               pfree(DatumGetPointer(ud));
-
        *result = tmp1 - size_box(origentry->key);
        PG_RETURN_POINTER(result);
 }
@@ -342,7 +339,6 @@ gbox_picksplit(PG_FUNCTION_ARGS)
                        else
                                ADDLIST(listT, unionT, posT, arr[i - 1].pos);
                }
-               pfree(arr);
        }
 
        /* which split more optimal? */
@@ -372,11 +368,6 @@ gbox_picksplit(PG_FUNCTION_ARGS)
 
        if (direction == 'x')
        {
-               pfree(unionB);
-               pfree(listB);
-               pfree(unionT);
-               pfree(listT);
-
                v->spl_left = listL;
                v->spl_right = listR;
                v->spl_nleft = posL;
@@ -386,11 +377,6 @@ gbox_picksplit(PG_FUNCTION_ARGS)
        }
        else
        {
-               pfree(unionR);
-               pfree(listR);
-               pfree(unionL);
-               pfree(listL);
-
                v->spl_left = listB;
                v->spl_right = listT;
                v->spl_nleft = posB;
@@ -497,9 +483,6 @@ gpoly_compress(PG_FUNCTION_ARGS)
                        in = (POLYGON *) PG_DETOAST_DATUM(entry->key);
                        r = (BOX *) palloc(sizeof(BOX));
                        memcpy((void *) r, (void *) &(in->boundbox), sizeof(BOX));
-                       if (in != (POLYGON *) DatumGetPointer(entry->key))
-                               pfree(in);
-
                        gistentryinit(*retval, PointerGetDatum(r),
                                                  entry->rel, entry->page,
                                                  entry->offset, sizeof(BOX), FALSE);
index 0de714854d0d3da1352abde31c1293c661a1946f..4bd9b9a59fdf208e09afea26001b47bfbfe5b779 100644 (file)
@@ -238,8 +238,6 @@ gseg_union(GistEntryVector *entryvec, int *sizep)
                out = gseg_binary_union(tmp, (SEG *)
                                                                DatumGetPointer(entryvec->vector[i].key),
                                                                sizep);
-               if (i > 1)
-                       pfree(tmp);
                tmp = out;
        }
 
@@ -278,7 +276,6 @@ gseg_penalty(GISTENTRY *origentry, GISTENTRY *newentry, float *result)
        rt_seg_size(ud, &tmp1);
        rt_seg_size((SEG *) DatumGetPointer(origentry->key), &tmp2);
        *result = tmp1 - tmp2;
-       pfree(ud);
 
 #ifdef GIST_DEBUG
        fprintf(stderr, "penalty\n");
@@ -351,16 +348,10 @@ gseg_picksplit(GistEntryVector *entryvec,
                        rt_seg_size(inter_d, &size_inter);
                        size_waste = size_union - size_inter;
 
-                       pfree(union_d);
-
-                       if (inter_d != (SEG *) NULL)
-                               pfree(inter_d);
-
                        /*
                         * are these a more promising split that what we've already
                         * seen?
                         */
-
                        if (size_waste > waste || firsttime)
                        {
                                waste = size_waste;
@@ -427,8 +418,6 @@ gseg_picksplit(GistEntryVector *entryvec,
                /* pick which page to add it to */
                if (size_alpha - size_l < size_beta - size_r)
                {
-                       pfree(datum_l);
-                       pfree(union_dr);
                        datum_l = union_dl;
                        size_l = size_alpha;
                        *left++ = i;
@@ -436,8 +425,6 @@ gseg_picksplit(GistEntryVector *entryvec,
                }
                else
                {
-                       pfree(datum_r);
-                       pfree(union_dl);
                        datum_r = union_dr;
                        size_r = size_alpha;
                        *right++ = i;
index 25b0d8d1e9fcc483b14fbebd3653c98b7e0d583e..c1e1e627fbf3f843a6054b6cf89d97ca0b456a35 100644 (file)
@@ -123,7 +123,6 @@ gtxtidx_compress(PG_FUNCTION_ARGS)
        if (entry->leafkey)
        {                                                       /* txtidx */
                GISTTYPE   *res;
-               txtidx     *toastedval = (txtidx *) DatumGetPointer(entry->key);
                txtidx     *val = (txtidx *) DatumGetPointer(PG_DETOAST_DATUM(entry->key));
                int4            len;
                int4       *arr;
@@ -154,8 +153,6 @@ gtxtidx_compress(PG_FUNCTION_ARGS)
                        res = (GISTTYPE *) repalloc((void *) res, len);
                        res->len = len;
                }
-               if (val != toastedval)
-                       pfree(val);
 
                /* make signature, if array is too long */
                if (res->len > TOAST_INDEX_TARGET)
@@ -167,7 +164,6 @@ gtxtidx_compress(PG_FUNCTION_ARGS)
                        ressign->len = len;
                        ressign->flag = SIGNKEY;
                        makesign(GETSIGN(ressign), res);
-                       pfree(res);
                        res = ressign;
                }
 
@@ -780,8 +776,6 @@ gtxtidx_picksplit(PG_FUNCTION_ARGS)
        }
 
        *right = *left = FirstOffsetNumber;
-       pfree(costvector);
-       pfree(cache);
        v->spl_ldatum = PointerGetDatum(datum_l);
        v->spl_rdatum = PointerGetDatum(datum_r);
 
index 58fbb974512e0ae84c55072027bc61de62bfe90c..de76b059cb6d68384c0b1824beffbf586a5ad6cf 100644 (file)
@@ -142,7 +142,6 @@ gtsvector_compress(PG_FUNCTION_ARGS)
        if (entry->leafkey)
        {                                                       /* tsvector */
                GISTTYPE   *res;
-               tsvector   *toastedval = (tsvector *) DatumGetPointer(entry->key);
                tsvector   *val = (tsvector *) DatumGetPointer(PG_DETOAST_DATUM(entry->key));
                int4            len;
                int4       *arr;
@@ -173,8 +172,6 @@ gtsvector_compress(PG_FUNCTION_ARGS)
                        res = (GISTTYPE *) repalloc((void *) res, len);
                        res->len = len;
                }
-               if (val != toastedval)
-                       pfree(val);
 
                /* make signature, if array is too long */
                if (res->len > TOAST_INDEX_TARGET)
@@ -186,7 +183,6 @@ gtsvector_compress(PG_FUNCTION_ARGS)
                        ressign->len = len;
                        ressign->flag = SIGNKEY;
                        makesign(GETSIGN(ressign), res);
-                       pfree(res);
                        res = ressign;
                }
 
@@ -734,8 +730,6 @@ gtsvector_picksplit(PG_FUNCTION_ARGS)
        }
 
        *right = *left = FirstOffsetNumber;
-       pfree(costvector);
-       pfree(cache);
        v->spl_ldatum = PointerGetDatum(datum_l);
        v->spl_rdatum = PointerGetDatum(datum_r);