aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-11-03 10:47:31 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2022-11-03 10:47:31 -0400
commitcf8b7d374ae10c8de389229ff924addc69e6f7df (patch)
tree4cd9be891600a7eb53b0b536f45745b814fcc63f /src
parent062eef3a9bbd5da9c26c93127ee6272193cb06e6 (diff)
downloadpostgresql-cf8b7d374ae10c8de389229ff924addc69e6f7df.tar.gz
postgresql-cf8b7d374ae10c8de389229ff924addc69e6f7df.zip
Add casts to simplehash.h to silence C++ warnings.
Casting the result of palloc etc. to the intended type is more per project style anyway. (The fact that cpluspluscheck doesn't notice these problems is because it doesn't expand any macros, which seems like a troubling shortcoming. Don't have a good idea about improving that.) Back-patch to v13, which is as far as the patch applies cleanly; doesn't seem worth working harder. David Geier Discussion: https://postgr.es/m/aa5d88a3-71f4-3455-11cf-82de0372c941@gmail.com
Diffstat (limited to 'src')
-rw-r--r--src/include/lib/simplehash.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/include/lib/simplehash.h b/src/include/lib/simplehash.h
index 329687c1a53..e8d5cc5c026 100644
--- a/src/include/lib/simplehash.h
+++ b/src/include/lib/simplehash.h
@@ -436,9 +436,9 @@ SH_CREATE(MemoryContext ctx, uint32 nelements, void *private_data)
uint64 size;
#ifdef SH_RAW_ALLOCATOR
- tb = SH_RAW_ALLOCATOR(sizeof(SH_TYPE));
+ tb = (SH_TYPE *) SH_RAW_ALLOCATOR(sizeof(SH_TYPE));
#else
- tb = MemoryContextAllocZero(ctx, sizeof(SH_TYPE));
+ tb = (SH_TYPE *) MemoryContextAllocZero(ctx, sizeof(SH_TYPE));
tb->ctx = ctx;
#endif
tb->private_data = private_data;
@@ -448,7 +448,7 @@ SH_CREATE(MemoryContext ctx, uint32 nelements, void *private_data)
SH_COMPUTE_PARAMETERS(tb, size);
- tb->data = SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
+ tb->data = (SH_ELEMENT_TYPE *) SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
return tb;
}
@@ -493,7 +493,7 @@ SH_GROW(SH_TYPE * tb, uint64 newsize)
/* compute parameters for new table */
SH_COMPUTE_PARAMETERS(tb, newsize);
- tb->data = SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
+ tb->data = (SH_ELEMENT_TYPE *) SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
newdata = tb->data;
@@ -1059,7 +1059,7 @@ SH_STAT(SH_TYPE * tb)
double fillfactor;
uint32 i;
- uint32 *collisions = palloc0(tb->size * sizeof(uint32));
+ uint32 *collisions = (uint32 *) palloc0(tb->size * sizeof(uint32));
uint32 total_collisions = 0;
uint32 max_collisions = 0;
double avg_collisions;