Skip to content

Commit a6983fa

Browse files
tglsfdcreshke
authored andcommitted
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
1 parent 88df9d7 commit a6983fa

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/include/lib/simplehash.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,9 @@ SH_CREATE(MemoryContext ctx, uint32 nelements, void *private_data)
452452
uint64 size;
453453

454454
#ifdef SH_RAW_ALLOCATOR
455-
tb = SH_RAW_ALLOCATOR(sizeof(SH_TYPE));
455+
tb = (SH_TYPE *) SH_RAW_ALLOCATOR(sizeof(SH_TYPE));
456456
#else
457-
tb = MemoryContextAllocZero(ctx, sizeof(SH_TYPE));
457+
tb = (SH_TYPE *) MemoryContextAllocZero(ctx, sizeof(SH_TYPE));
458458
tb->ctx = ctx;
459459
#endif
460460
tb->private_data = private_data;
@@ -464,7 +464,7 @@ SH_CREATE(MemoryContext ctx, uint32 nelements, void *private_data)
464464

465465
SH_COMPUTE_PARAMETERS(tb, size);
466466

467-
tb->data = SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
467+
tb->data = (SH_ELEMENT_TYPE *) SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
468468
tb->num_expansions = 0;
469469

470470
return tb;
@@ -511,7 +511,7 @@ SH_GROW(SH_TYPE * tb, uint64 newsize)
511511
/* compute parameters for new table */
512512
SH_COMPUTE_PARAMETERS(tb, newsize);
513513

514-
tb->data = SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
514+
tb->data = (SH_ELEMENT_TYPE *) SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
515515

516516
newdata = tb->data;
517517

@@ -1078,7 +1078,7 @@ SH_STAT(SH_TYPE * tb)
10781078
double fillfactor;
10791079
uint32 i;
10801080

1081-
uint32 *collisions = palloc0(tb->size * sizeof(uint32));
1081+
uint32 *collisions = (uint32 *) palloc0(tb->size * sizeof(uint32));
10821082
uint32 total_collisions = 0;
10831083
uint32 max_collisions = 0;
10841084
double avg_collisions;

0 commit comments

Comments
 (0)