From: Neil Conway Date: Sat, 21 May 2005 12:08:06 +0000 (+0000) Subject: Cleanup of GiST extensions in contrib/: now that we always invoke GiST X-Git-Tag: REL8_1_0BETA1~758 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=36ab6005119532903d4ce3ad564e6576bd7698b8;p=postgresql Cleanup of GiST extensions in contrib/: now that we always invoke GiST methods in a short-lived memory context, there is no need for GiST methods to do their own manual (and error-prone) memory management. --- diff --git a/contrib/btree_gist/btree_bit.c b/contrib/btree_gist/btree_bit.c index 0cdd277a12..0c7108bc60 100644 --- a/contrib/btree_gist/btree_bit.c +++ b/contrib/btree_gist/btree_bit.c @@ -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); } diff --git a/contrib/btree_gist/btree_bytea.c b/contrib/btree_gist/btree_bytea.c index 79095fc0e9..375cc26cc6 100644 --- a/contrib/btree_gist/btree_bytea.c +++ b/contrib/btree_gist/btree_bytea.c @@ -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); } diff --git a/contrib/btree_gist/btree_numeric.c b/contrib/btree_gist/btree_numeric.c index d9c3184fe6..fcfd4613ef 100644 --- a/contrib/btree_gist/btree_numeric.c +++ b/contrib/btree_gist/btree_numeric.c @@ -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); } diff --git a/contrib/btree_gist/btree_text.c b/contrib/btree_gist/btree_text.c index 50b81ab045..d81e7d0fd9 100644 --- a/contrib/btree_gist/btree_text.c +++ b/contrib/btree_gist/btree_text.c @@ -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) { diff --git a/contrib/btree_gist/btree_time.c b/contrib/btree_gist/btree_time.c index c55385ea82..491d05b631 100644 --- a/contrib/btree_gist/btree_time.c +++ b/contrib/btree_gist/btree_time.c @@ -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); diff --git a/contrib/btree_gist/btree_ts.c b/contrib/btree_gist/btree_ts.c index aaa0c2e5a4..3d5defe3db 100644 --- a/contrib/btree_gist/btree_ts.c +++ b/contrib/btree_gist/btree_ts.c @@ -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); - } diff --git a/contrib/btree_gist/btree_utils_num.c b/contrib/btree_gist/btree_utils_num.c index ab4355e6fe..69292758f5 100644 --- a/contrib/btree_gist/btree_utils_num.c +++ b/contrib/btree_gist/btree_utils_num.c @@ -246,7 +246,5 @@ gbt_num_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v, } } - pfree(arr); - return v; } diff --git a/contrib/btree_gist/btree_utils_var.c b/contrib/btree_gist/btree_utils_var.c index d751a11f0e..720381428f 100644 --- a/contrib/btree_gist/btree_utils_var.c +++ b/contrib/btree_gist/btree_utils_var.c @@ -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; } diff --git a/contrib/cube/cube.c b/contrib/cube/cube.c index 658536ac4d..fd0609ee26 100644 --- a/contrib/cube/cube.c +++ b/contrib/cube/cube.c @@ -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; diff --git a/contrib/ltree/_ltree_gist.c b/contrib/ltree/_ltree_gist.c index 50a38405c6..f68e9902b5 100644 --- a/contrib/ltree/_ltree_gist.c +++ b/contrib/ltree/_ltree_gist.c @@ -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); diff --git a/contrib/ltree/ltree_gist.c b/contrib/ltree/ltree_gist.c index ec81ce1c18..693244d9da 100644 --- a/contrib/ltree/ltree_gist.c +++ b/contrib/ltree/ltree_gist.c @@ -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); diff --git a/contrib/pg_trgm/trgm_gist.c b/contrib/pg_trgm/trgm_gist.c index 3ae8f4b3aa..33ed6d5e1f 100644 --- a/contrib/pg_trgm/trgm_gist.c +++ b/contrib/pg_trgm/trgm_gist.c @@ -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); diff --git a/contrib/rtree_gist/rtree_gist.c b/contrib/rtree_gist/rtree_gist.c index 92714522d8..d2f4156920 100644 --- a/contrib/rtree_gist/rtree_gist.c +++ b/contrib/rtree_gist/rtree_gist.c @@ -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); diff --git a/contrib/seg/seg.c b/contrib/seg/seg.c index 0de714854d..4bd9b9a59f 100644 --- a/contrib/seg/seg.c +++ b/contrib/seg/seg.c @@ -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; diff --git a/contrib/tsearch/gistidx.c b/contrib/tsearch/gistidx.c index 25b0d8d1e9..c1e1e627fb 100644 --- a/contrib/tsearch/gistidx.c +++ b/contrib/tsearch/gistidx.c @@ -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); diff --git a/contrib/tsearch2/gistidx.c b/contrib/tsearch2/gistidx.c index 58fbb97451..de76b059cb 100644 --- a/contrib/tsearch2/gistidx.c +++ b/contrib/tsearch2/gistidx.c @@ -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);