Skip to content

Commit c43dbbc

Browse files
author
Sokolov Yura
committed
cfs: a bit prettify cfs_shmem_size
1 parent 8bd21f5 commit c43dbbc

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/backend/storage/file/cfs.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,9 @@ void cfs_decrypt(const char* fname, void* block, uint32 offs, uint32 size)
391391
* Section 3: Compression implementation.
392392
* ----------------------------------------------------------------
393393
*/
394-
int cfs_shmem_size()
394+
size_t cfs_shmem_size()
395395
{
396-
return sizeof(CfsState) + sizeof(pg_atomic_uint32)*MaxBackends;
396+
return add_size(sizeof(CfsState), mul_size(sizeof(pg_atomic_uint32), MaxBackends));
397397
}
398398

399399
void cfs_initialize()
@@ -405,8 +405,7 @@ void cfs_initialize()
405405
StaticAssertStmt(CFS_GC_LOCK > MAX_BACKENDS,
406406
"CFS_GC_LOCK should be larger than MAX_BACKENDS");
407407

408-
cfs_state = (CfsState*)ShmemInitStruct("CFS Control",
409-
sizeof(CfsState) + sizeof(pg_atomic_uint32)*MaxBackends, &found);
408+
cfs_state = (CfsState*)ShmemInitStruct("CFS Control", cfs_shmem_size(), &found);
410409
if (!found)
411410
{
412411
int i;

src/include/storage/cfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ int cfs_msync(FileMap* map);
133133
FileMap* cfs_mmap(int md);
134134
int cfs_munmap(FileMap* map);
135135
void cfs_initialize(void);
136-
int cfs_shmem_size(void);
136+
size_t cfs_shmem_size(void);
137137

138138
void cfs_encrypt(const char* fname, void* block, uint32 offs, uint32 size);
139139
void cfs_decrypt(const char* fname, void* block, uint32 offs, uint32 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