Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 725cd4d

Browse files
committed
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 a5737e7 commit 725cd4d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/include/lib/simplehash.h

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

438438
#ifdef SH_RAW_ALLOCATOR
439-
tb = SH_RAW_ALLOCATOR(sizeof(SH_TYPE));
439+
tb = (SH_TYPE *) SH_RAW_ALLOCATOR(sizeof(SH_TYPE));
440440
#else
441-
tb = MemoryContextAllocZero(ctx, sizeof(SH_TYPE));
441+
tb = (SH_TYPE *) MemoryContextAllocZero(ctx, sizeof(SH_TYPE));
442442
tb->ctx = ctx;
443443
#endif
444444
tb->private_data = private_data;
@@ -448,7 +448,7 @@ SH_CREATE(MemoryContext ctx, uint32 nelements, void *private_data)
448448

449449
SH_COMPUTE_PARAMETERS(tb, size);
450450

451-
tb->data = SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
451+
tb->data = (SH_ELEMENT_TYPE *) SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
452452

453453
return tb;
454454
}
@@ -493,7 +493,7 @@ SH_GROW(SH_TYPE * tb, uint64 newsize)
493493
/* compute parameters for new table */
494494
SH_COMPUTE_PARAMETERS(tb, newsize);
495495

496-
tb->data = SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
496+
tb->data = (SH_ELEMENT_TYPE *) SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
497497

498498
newdata = tb->data;
499499

@@ -1059,7 +1059,7 @@ SH_STAT(SH_TYPE * tb)
10591059
double fillfactor;
10601060
uint32 i;
10611061

1062-
uint32 *collisions = palloc0(tb->size * sizeof(uint32));
1062+
uint32 *collisions = (uint32 *) palloc0(tb->size * sizeof(uint32));
10631063
uint32 total_collisions = 0;
10641064
uint32 max_collisions = 0;
10651065
double avg_collisions;

0 commit comments

Comments
 (0)