Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5046708

Browse files
committed
Add casts to simplehash.h to silence C++ warnings.
Casting the result of palloc etc. to the intended type is more perproject style anyway.(The fact that cpluspluscheck doesn't notice these problems isbecause it doesn't expand any macros, which seems like a troublingshortcoming. 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 GeierDiscussion:https://postgr.es/m/aa5d88a3-71f4-3455-11cf-82de0372c941@gmail.com
1 parentc479492 commit5046708

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
@@ -367,9 +367,9 @@ SH_CREATE(MemoryContext ctx, uint32 nelements, void *private_data)
367367
uint64size;
368368

369369
#ifdefSH_RAW_ALLOCATOR
370-
tb=SH_RAW_ALLOCATOR(sizeof(SH_TYPE));
370+
tb=(SH_TYPE*)SH_RAW_ALLOCATOR(sizeof(SH_TYPE));
371371
#else
372-
tb=MemoryContextAllocZero(ctx,sizeof(SH_TYPE));
372+
tb=(SH_TYPE*)MemoryContextAllocZero(ctx,sizeof(SH_TYPE));
373373
tb->ctx=ctx;
374374
#endif
375375
tb->private_data=private_data;
@@ -379,7 +379,7 @@ SH_CREATE(MemoryContext ctx, uint32 nelements, void *private_data)
379379

380380
SH_COMPUTE_PARAMETERS(tb,size);
381381

382-
tb->data=SH_ALLOCATE(tb,sizeof(SH_ELEMENT_TYPE)*tb->size);
382+
tb->data=(SH_ELEMENT_TYPE*)SH_ALLOCATE(tb,sizeof(SH_ELEMENT_TYPE)*tb->size);
383383

384384
returntb;
385385
}
@@ -424,7 +424,7 @@ SH_GROW(SH_TYPE * tb, uint64 newsize)
424424
/* compute parameters for new table */
425425
SH_COMPUTE_PARAMETERS(tb,newsize);
426426

427-
tb->data=SH_ALLOCATE(tb,sizeof(SH_ELEMENT_TYPE)*tb->size);
427+
tb->data=(SH_ELEMENT_TYPE*)SH_ALLOCATE(tb,sizeof(SH_ELEMENT_TYPE)*tb->size);
428428

429429
newdata=tb->data;
430430

@@ -935,7 +935,7 @@ SH_STAT(SH_TYPE * tb)
935935
doublefillfactor;
936936
uint32i;
937937

938-
uint32*collisions=palloc0(tb->size*sizeof(uint32));
938+
uint32*collisions=(uint32*)palloc0(tb->size*sizeof(uint32));
939939
uint32total_collisions=0;
940940
uint32max_collisions=0;
941941
doubleavg_collisions;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp