From: Vadim B. Mikheev Date: Thu, 21 Nov 1996 06:02:56 +0000 (+0000) Subject: Fix memory overhelding while forming index' result: X-Git-Tag: REL2_0~77 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=05b3b8613db1482157c5d2b218f4d96b48cb6d2b;p=postgresql Fix memory overhelding while forming index' result: memory allocation for ItemPointerData of heap' tuple is useless because of FormRetrieveIndexResult makes neccessary palloc. --- diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gistget.c index 1a9a01a6a8..afd34be144 100644 --- a/src/backend/access/gist/gistget.c +++ b/src/backend/access/gist/gistget.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * /usr/local/devel/pglite/cvs/src/backend/access/gisr/gistget.c,v 1.9 1995/08/01 20:16:02 jolly Exp + * /usr/local/devel/pglite/cvs/src/backend/access/gisr/gistget.c,v 1.9.1 1996/11/21 01:00:00 vadim Exp * *------------------------------------------------------------------------- */ @@ -67,7 +67,6 @@ gistfirst(IndexScanDesc s, ScanDirection dir) GISTSTACK *stk; BlockNumber blk; IndexTuple it; - ItemPointer ip; b = ReadBuffer(s->relation, GISTP_ROOT); p = BufferGetPage(b); @@ -107,13 +106,10 @@ gistfirst(IndexScanDesc s, ScanDirection dir) ItemPointerSet(&(s->currentItemData), BufferGetBlockNumber(b), n); it = (IndexTuple) PageGetItem(p, PageGetItemId(p, n)); - ip = (ItemPointer) palloc(sizeof(ItemPointerData)); - memmove((char *) ip, (char *) &(it->t_tid), - sizeof(ItemPointerData)); - ReleaseBuffer(b); - - res = FormRetrieveIndexResult(&(s->currentItemData), ip); + + res = FormRetrieveIndexResult(&(s->currentItemData), &(it->t_tid)); + ReleaseBuffer(b); return (res); } else { stk = (GISTSTACK *) palloc(sizeof(GISTSTACK)); @@ -146,7 +142,6 @@ gistnext(IndexScanDesc s, ScanDirection dir) GISTSTACK *stk; BlockNumber blk; IndexTuple it; - ItemPointer ip; blk = ItemPointerGetBlockNumber(&(s->currentItemData)); n = ItemPointerGetOffsetNumber(&(s->currentItemData)); @@ -192,13 +187,10 @@ gistnext(IndexScanDesc s, ScanDirection dir) ItemPointerSet(&(s->currentItemData), BufferGetBlockNumber(b), n); it = (IndexTuple) PageGetItem(p, PageGetItemId(p, n)); - ip = (ItemPointer) palloc(sizeof(ItemPointerData)); - memmove((char *) ip, (char *) &(it->t_tid), - sizeof(ItemPointerData)); - ReleaseBuffer(b); - res = FormRetrieveIndexResult(&(s->currentItemData), ip); + res = FormRetrieveIndexResult(&(s->currentItemData), &(it->t_tid)); + ReleaseBuffer(b); return (res); } else { stk = (GISTSTACK *) palloc(sizeof(GISTSTACK)); @@ -340,6 +332,8 @@ gistscancache(IndexScanDesc s, ScanDirection dir) res = FormRetrieveIndexResult(&(s->currentItemData), ip); else res = (RetrieveIndexResult) NULL; + + pfree (ip); return (res); }