summaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlog.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r--src/backend/access/transam/xlog.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 42ec2fe71de..6b9209d882a 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -2348,6 +2348,7 @@ XLogFileInit(uint32 log, uint32 seg,
{
char path[MAXPGPATH];
char tmppath[MAXPGPATH];
+ char zbuffer_raw[BLCKSZ + MAXIMUM_ALIGNOF];
char *zbuffer;
uint32 installed_log;
uint32 installed_seg;
@@ -2405,11 +2406,11 @@ XLogFileInit(uint32 log, uint32 seg,
* fdatasync(2) or O_DSYNC will be sufficient to sync future writes to the
* log file.
*
- * Note: palloc zbuffer, instead of just using a local char array, to
- * ensure it is reasonably well-aligned; this may save a few cycles
- * transferring data to the kernel.
+ * Note: ensure the buffer is reasonably well-aligned; this may save a few
+ * cycles transferring data to the kernel.
*/
- zbuffer = (char *) palloc0(XLOG_BLCKSZ);
+ zbuffer = (char *) MAXALIGN(zbuffer_raw);
+ memset(zbuffer, 0, BLCKSZ);
for (nbytes = 0; nbytes < XLogSegSize; nbytes += XLOG_BLCKSZ)
{
errno = 0;
@@ -2429,7 +2430,6 @@ XLogFileInit(uint32 log, uint32 seg,
errmsg("could not write to file \"%s\": %m", tmppath)));
}
}
- pfree(zbuffer);
if (pg_fsync(fd) != 0)
ereport(ERROR,