Change some mallocs to palloc.

This commit is contained in:
Bruce Momjian 1997-12-29 05:13:57 +00:00
parent a1dd409053
commit a544b605e2
5 changed files with 12 additions and 15 deletions

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.15 1997/11/25 21:58:53 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.16 1997/12/29 05:13:22 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -68,7 +68,7 @@ ExplainQuery(Query *query, bool verbose, CommandDest dest)
if (plan == NULL) if (plan == NULL)
return; return;
es = (ExplainState *) malloc(sizeof(ExplainState)); es = (ExplainState *) palloc(sizeof(ExplainState));
MemSet(es, 0, sizeof(ExplainState)); MemSet(es, 0, sizeof(ExplainState));
es->printCost = true; /* default */ es->printCost = true; /* default */
@ -103,7 +103,7 @@ ExplainQuery(Query *query, bool verbose, CommandDest dest)
elog(NOTICE, "%.*s", ELOG_MAXLEN - 64, s); elog(NOTICE, "%.*s", ELOG_MAXLEN - 64, s);
len -= ELOG_MAXLEN - 64; len -= ELOG_MAXLEN - 64;
} }
free(es); pfree(es);
} }
/***************************************************************************** /*****************************************************************************

View File

@ -266,11 +266,11 @@ ExecAgg(Agg *node)
tupValue = projInfo->pi_tupValue; tupValue = projInfo->pi_tupValue;
/* initially, set all the values to NULL */ /* initially, set all the values to NULL */
null_array = malloc(tupType->natts); null_array = palloc(tupType->natts);
for (i = 0; i < tupType->natts; i++) for (i = 0; i < tupType->natts; i++)
null_array[i] = 'n'; null_array[i] = 'n';
oneTuple = heap_formtuple(tupType, tupValue, null_array); oneTuple = heap_formtuple(tupType, tupValue, null_array);
free(null_array); pfree(null_array);
} }
break; break;
} }

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.59 1997/12/29 04:31:28 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.60 1997/12/29 05:13:35 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -51,7 +51,6 @@ List *extras = NIL;
* Returns a list of transformed parse trees. Optimizable statements are * Returns a list of transformed parse trees. Optimizable statements are
* all transformed to Query while the rest stays the same. * all transformed to Query while the rest stays the same.
* *
* CALLER is responsible for freeing the QueryTreeList* returned
*/ */
QueryTreeList * QueryTreeList *
parse_analyze(List *pl) parse_analyze(List *pl)
@ -82,7 +81,7 @@ parse_analyze(List *pl)
pl = lnext(pl); pl = lnext(pl);
if (pstate->p_target_relation != NULL) if (pstate->p_target_relation != NULL)
heap_close(pstate->p_target_relation); heap_close(pstate->p_target_relation);
free(pstate); pfree(pstate);
} }
return result; return result;

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.3 1997/11/26 03:42:44 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.4 1997/12/29 05:13:46 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -46,7 +46,7 @@ make_parsestate(void)
{ {
ParseState *pstate; ParseState *pstate;
pstate = malloc(sizeof(ParseState)); pstate = palloc(sizeof(ParseState));
pstate->p_last_resno = 1; pstate->p_last_resno = 1;
pstate->p_rtable = NIL; pstate->p_rtable = NIL;
pstate->p_numAgg = 0; pstate->p_numAgg = 0;

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.20 1997/11/24 05:08:54 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.21 1997/12/29 05:13:57 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -580,7 +580,6 @@ aclcontains(Acl *acl, AclItem *aip)
* *
* does not add duplicate privileges * does not add duplicate privileges
* *
* the CALLER is reponsible for free'ing the string returned
*/ */
char * char *
@ -591,7 +590,7 @@ aclmakepriv(char *old_privlist, char new_priv)
int l; int l;
Assert(strlen(old_privlist) < 5); Assert(strlen(old_privlist) < 5);
priv = malloc(5); /* at most "rwaR" */ ; priv = palloc(5); /* at most "rwaR" */ ;
if (old_privlist == NULL || old_privlist[0] == '\0') if (old_privlist == NULL || old_privlist[0] == '\0')
{ {
@ -634,7 +633,6 @@ aclmakepriv(char *old_privlist, char new_priv)
* *
* this routine is used in the parser * this routine is used in the parser
* *
* the CALLER is responsible for freeing the memory allocated
*/ */
char * char *
@ -642,7 +640,7 @@ aclmakeuser(char *user_type, char *user)
{ {
char *user_list; char *user_list;
user_list = malloc(strlen(user) + 3); user_list = palloc(strlen(user) + 3);
sprintf(user_list, "%s %s", user_type, user); sprintf(user_list, "%s %s", user_type, user);
return user_list; return user_list;
} }