From: Vadim B. Mikheev Date: Tue, 20 May 1997 11:35:50 +0000 (+0000) Subject: Shouldn't we use palloc instead of malloc ? X-Git-Tag: REL9_0_0~28830 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=5f893a1e32893d42f6b5c3cd9844564ab2cdfdf1;p=pg-rex%2Fsyncrep.git Shouldn't we use palloc instead of malloc ? Because of * resetpsort - resets (frees) malloc'd memory for an aborted Xaction * * Not implemented yet. --- diff --git a/src/backend/utils/sort/lselect.c b/src/backend/utils/sort/lselect.c index 635dbd771c..8c6c27ef46 100644 --- a/src/backend/utils/sort/lselect.c +++ b/src/backend/utils/sort/lselect.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/lselect.c,v 1.2 1996/11/03 06:54:35 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/lselect.c,v 1.3 1997/05/20 11:35:48 vadim Exp $ * *------------------------------------------------------------------------- */ @@ -43,7 +43,7 @@ extern Relation SortRdesc; /* later static */ #define PUTTUP(TUP, FP) fwrite((char *)TUP, (TUP)->t_len, 1, FP) #define ENDRUN(FP) fwrite((char *)&shortzero, sizeof (shortzero), 1, FP) #define GETLEN(LEN, FP) fread(&(LEN), sizeof (shortzero), 1, FP) -#define ALLOCTUP(LEN) ((HeapTuple)malloc((unsigned)LEN)) +#define ALLOCTUP(LEN) ((HeapTuple)palloc((unsigned)LEN)) #define GETTUP(TUP, LEN, FP)\ fread((char *)(TUP) + sizeof (shortzero), 1, (LEN) - sizeof (shortzero), FP) #define SETTUPLEN(TUP, LEN) (TUP)->t_len = LEN @@ -175,7 +175,7 @@ puttuple(struct leftist **treep, HeapTuple newtuple, int devnum) register struct leftist *new1; register struct leftist *tp; - new1 = (struct leftist *) malloc((unsigned) sizeof (struct leftist)); + new1 = (struct leftist *) palloc((unsigned) sizeof (struct leftist)); USEMEM(sizeof (struct leftist)); new1->lt_dist = 1; new1->lt_devnum = devnum; diff --git a/src/backend/utils/sort/psort.c b/src/backend/utils/sort/psort.c index cac308b97f..613fbff23d 100644 --- a/src/backend/utils/sort/psort.c +++ b/src/backend/utils/sort/psort.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.3 1996/11/06 10:32:10 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.4 1997/05/20 11:35:50 vadim Exp $ * * NOTES * Sorts the first relation into the second relation. The sort may @@ -175,7 +175,7 @@ resetpsort() fwrite((char *)TUP, (TUP)->t_len, 1, FP) #define ENDRUN(FP) fwrite((char *)&shortzero, sizeof (shortzero), 1, FP) #define GETLEN(LEN, FP) fread((char *)&(LEN), sizeof (shortzero), 1, FP) -#define ALLOCTUP(LEN) ((HeapTuple)malloc((unsigned)LEN)) +#define ALLOCTUP(LEN) ((HeapTuple)palloc((unsigned)LEN)) #define GETTUP(TUP, LEN, FP)\ IncrProcessed(); \ BytesRead += (LEN) - sizeof (shortzero); \ @@ -349,7 +349,7 @@ tuplecopy(HeapTuple tup, Relation rdesc, Buffer b) if (!HeapTupleIsValid(tup)) { return(NULL); /* just in case */ } - rettup = (HeapTuple)malloc(tup->t_len); + rettup = (HeapTuple)palloc(tup->t_len); memmove((char *)rettup, (char *)tup, tup->t_len); /* XXX */ return(rettup); } @@ -527,13 +527,13 @@ gettape() static int tapeinit = 0; char *mktemp(); - tp = (struct tapelst *)malloc((unsigned)sizeof (struct tapelst)); + tp = (struct tapelst *)palloc((unsigned)sizeof (struct tapelst)); if (!tapeinit) { Tempfile[sizeof (TEMPDIR) - 1] = '/'; memmove(Tempfile + sizeof(TEMPDIR), TAPEEXT, sizeof (TAPEEXT)); tapeinit = 1; } - tp->tl_name = malloc((unsigned)sizeof(Tempfile)); + tp->tl_name = palloc((unsigned)sizeof(Tempfile)); /* * now, copy template with final null into malloc'd space */