mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Tweak palloc/repalloc to allow zero bytes to be requested, as per recent
proposal. Eliminate several dozen now-unnecessary hacks to avoid palloc(0). (It's likely there are more that I didn't find.)
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/freespace/freespace.c,v 1.30 2004/01/26 22:35:32 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/freespace/freespace.c,v 1.31 2004/06/05 19:48:08 tgl Exp $
|
||||
*
|
||||
*
|
||||
* NOTES:
|
||||
@@ -893,7 +893,7 @@ LoadFreeSpaceMap(void)
|
||||
len = nPages * sizeof(IndexFSMPageData);
|
||||
else
|
||||
len = nPages * sizeof(FSMPageData);
|
||||
data = (char *) palloc(len + 1); /* +1 to avoid palloc(0) */
|
||||
data = (char *) palloc(len);
|
||||
if (fread(data, 1, len, fp) != len)
|
||||
{
|
||||
elog(LOG, "premature EOF in \"%s\"", cachefilename);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/deadlock.c,v 1.27 2003/12/01 21:59:25 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/deadlock.c,v 1.28 2004/06/05 19:48:08 tgl Exp $
|
||||
*
|
||||
* Interface:
|
||||
*
|
||||
@@ -147,11 +147,10 @@ InitDeadLockChecking(void)
|
||||
* We need to consider rearranging at most MaxBackends/2 wait queues
|
||||
* (since it takes at least two waiters in a queue to create a soft
|
||||
* edge), and the expanded form of the wait queues can't involve more
|
||||
* than MaxBackends total waiters. (But avoid palloc(0) if
|
||||
* MaxBackends = 1.)
|
||||
* than MaxBackends total waiters.
|
||||
*/
|
||||
waitOrders = (WAIT_ORDER *)
|
||||
palloc(((MaxBackends + 1) / 2) * sizeof(WAIT_ORDER));
|
||||
palloc((MaxBackends / 2) * sizeof(WAIT_ORDER));
|
||||
waitOrderProcs = (PGPROC **) palloc(MaxBackends * sizeof(PGPROC *));
|
||||
|
||||
/*
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.132 2004/05/28 05:13:05 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.133 2004/06/05 19:48:08 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Outside modules can create a lock table and acquire/release
|
||||
@@ -1361,9 +1361,6 @@ GetLockStatusData(void)
|
||||
|
||||
data->nelements = i = proclockTable->hctl->nentries;
|
||||
|
||||
if (i == 0)
|
||||
i = 1; /* avoid palloc(0) if empty table */
|
||||
|
||||
data->proclockaddrs = (SHMEM_OFFSET *) palloc(sizeof(SHMEM_OFFSET) * i);
|
||||
data->proclocks = (PROCLOCK *) palloc(sizeof(PROCLOCK) * i);
|
||||
data->procs = (PGPROC *) palloc(sizeof(PGPROC) * i);
|
||||
|
||||
Reference in New Issue
Block a user