Skip to content

Add explicit casts to *alloc and djb2 calls#18

Open
vassvik wants to merge 1 commit into
robstolarz:masterfrom
vassvik:master
Open

Add explicit casts to *alloc and djb2 calls#18
vassvik wants to merge 1 commit into
robstolarz:masterfrom
vassvik:master

Conversation

@vassvik

@vassvik vassvik commented Aug 16, 2018

Copy link
Copy Markdown

The void * return value of realloc and calloc needs to be explicitly cast for C++ compliance. The djb2 function takes const unsigned char * as input, but a char * is passed, so we need to explicitly cast it for C++ compliance.

The `void *` return value of realloc and calloc needs to be explicitly cast for C++ compliance. The djb2 function takes `const unsigned char *` as input, but a `char *` is passed, so we need to explicitly cast it for C++ compliance.
@robstolarz robstolarz self-requested a review August 16, 2018 19:25
Comment thread src/rsht.c
// bool: did it work?
static bool setcapacity(rsht_ht *ht, const size_t capacity) {
rsht_entry *items = realloc(ht->items, capacity * sizeof(rsht_entry));
rsht_entry *items = (rsht_entry *)realloc(ht->items, capacity * sizeof(rsht_entry));

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you put a space between casts and things they cast?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants