Skip to content

Commit faf3750

Browse files
committed
Add const to BufFileWrite
Make data buffer argument to BufFileWrite a const pointer and bubble this up to various callers and related APIs. This makes the APIs clearer and more consistent. Discussion: https://www.postgresql.org/message-id/flat/11dda853-bb5b-59ba-a746-e168b1ce4bdb%40enterprisedb.com
1 parent 5f2f99c commit faf3750

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

src/backend/access/gist/gistbuildbuffers.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static long gistBuffersGetFreeBlock(GISTBuildBuffers *gfbb);
3838
static void gistBuffersReleaseBlock(GISTBuildBuffers *gfbb, long blocknum);
3939

4040
static void ReadTempFileBlock(BufFile *file, long blknum, void *ptr);
41-
static void WriteTempFileBlock(BufFile *file, long blknum, void *ptr);
41+
static void WriteTempFileBlock(BufFile *file, long blknum, const void *ptr);
4242

4343

4444
/*
@@ -764,7 +764,7 @@ ReadTempFileBlock(BufFile *file, long blknum, void *ptr)
764764
}
765765

766766
static void
767-
WriteTempFileBlock(BufFile *file, long blknum, void *ptr)
767+
WriteTempFileBlock(BufFile *file, long blknum, const void *ptr)
768768
{
769769
if (BufFileSeekBlock(file, blknum) != 0)
770770
elog(ERROR, "could not seek to block %ld in temporary file", blknum);

src/backend/backup/backup_manifest.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "utils/builtins.h"
2222
#include "utils/json.h"
2323

24-
static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
24+
static void AppendStringToManifest(backup_manifest_info *manifest, const char *s);
2525

2626
/*
2727
* Does the user want a backup manifest?
@@ -385,7 +385,7 @@ SendBackupManifest(backup_manifest_info *manifest, bbsink *sink)
385385
* Append a cstring to the manifest.
386386
*/
387387
static void
388-
AppendStringToManifest(backup_manifest_info *manifest, char *s)
388+
AppendStringToManifest(backup_manifest_info *manifest, const char *s)
389389
{
390390
int len = strlen(s);
391391

src/backend/storage/file/buffile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ BufFileRead(BufFile *file, void *ptr, size_t size)
622622
* ereport().
623623
*/
624624
void
625-
BufFileWrite(BufFile *file, void *ptr, size_t size)
625+
BufFileWrite(BufFile *file, const void *ptr, size_t size)
626626
{
627627
size_t nthistime;
628628

@@ -655,7 +655,7 @@ BufFileWrite(BufFile *file, void *ptr, size_t size)
655655
file->pos += nthistime;
656656
if (file->nbytes < file->pos)
657657
file->nbytes = file->pos;
658-
ptr = (char *) ptr + nthistime;
658+
ptr = (const char *) ptr + nthistime;
659659
size -= nthistime;
660660
}
661661
}

src/backend/utils/sort/logtape.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ struct LogicalTapeSet
220220
};
221221

222222
static LogicalTape *ltsCreateTape(LogicalTapeSet *lts);
223-
static void ltsWriteBlock(LogicalTapeSet *lts, long blocknum, void *buffer);
223+
static void ltsWriteBlock(LogicalTapeSet *lts, long blocknum, const void *buffer);
224224
static void ltsReadBlock(LogicalTapeSet *lts, long blocknum, void *buffer);
225225
static long ltsGetBlock(LogicalTapeSet *lts, LogicalTape *lt);
226226
static long ltsGetFreeBlock(LogicalTapeSet *lts);
@@ -235,7 +235,7 @@ static void ltsInitReadBuffer(LogicalTape *lt);
235235
* No need for an error return convention; we ereport() on any error.
236236
*/
237237
static void
238-
ltsWriteBlock(LogicalTapeSet *lts, long blocknum, void *buffer)
238+
ltsWriteBlock(LogicalTapeSet *lts, long blocknum, const void *buffer)
239239
{
240240
/*
241241
* BufFile does not support "holes", so if we're about to write a block
@@ -759,7 +759,7 @@ LogicalTapeSetForgetFreeSpace(LogicalTapeSet *lts)
759759
* There are no error returns; we ereport() on failure.
760760
*/
761761
void
762-
LogicalTapeWrite(LogicalTape *lt, void *ptr, size_t size)
762+
LogicalTapeWrite(LogicalTape *lt, const void *ptr, size_t size)
763763
{
764764
LogicalTapeSet *lts = lt->tapeSet;
765765
size_t nthistime;
@@ -826,7 +826,7 @@ LogicalTapeWrite(LogicalTape *lt, void *ptr, size_t size)
826826
lt->pos += nthistime;
827827
if (lt->nbytes < lt->pos)
828828
lt->nbytes = lt->pos;
829-
ptr = (char *) ptr + nthistime;
829+
ptr = (const char *) ptr + nthistime;
830830
size -= nthistime;
831831
}
832832
}

src/include/storage/buffile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ typedef struct BufFile BufFile;
3939
extern BufFile *BufFileCreateTemp(bool interXact);
4040
extern void BufFileClose(BufFile *file);
4141
extern size_t BufFileRead(BufFile *file, void *ptr, size_t size);
42-
extern void BufFileWrite(BufFile *file, void *ptr, size_t size);
42+
extern void BufFileWrite(BufFile *file, const void *ptr, size_t size);
4343
extern int BufFileSeek(BufFile *file, int fileno, off_t offset, int whence);
4444
extern void BufFileTell(BufFile *file, int *fileno, off_t *offset);
4545
extern int BufFileSeekBlock(BufFile *file, long blknum);

src/include/utils/logtape.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ extern LogicalTape *LogicalTapeCreate(LogicalTapeSet *lts);
6666
extern LogicalTape *LogicalTapeImport(LogicalTapeSet *lts, int worker, TapeShare *shared);
6767
extern void LogicalTapeSetForgetFreeSpace(LogicalTapeSet *lts);
6868
extern size_t LogicalTapeRead(LogicalTape *lt, void *ptr, size_t size);
69-
extern void LogicalTapeWrite(LogicalTape *lt, void *ptr, size_t size);
69+
extern void LogicalTapeWrite(LogicalTape *lt, const void *ptr, size_t size);
7070
extern void LogicalTapeRewindForRead(LogicalTape *lt, size_t buffer_size);
7171
extern void LogicalTapeFreeze(LogicalTape *lt, TapeShare *share);
7272
extern size_t LogicalTapeBackspace(LogicalTape *lt, size_t size);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy