Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explicit casts to *alloc and djb2 calls #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vassvik
Copy link

@vassvik vassvik commented Aug 16, 2018

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
@@ -34,7 +34,7 @@ static unsigned long djb2(const unsigned char *str) {

// 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
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