Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
I think
-1
and0
are equally bad (as a caller might be unaware that the function also uses the output parameter as an error indicator and may end up callingmalloc(utf8_strlen(x))
).I guess a better way would be?
uint32_t utf8_strlen(char *, uint8_t * errcode);
Returning
0
for invalid string is probably a bad idea. Shouldn't-1
be returned instead?Re-published, thanks.
<stdint.h>
should be included in Sample Tests.I did, thanks.
Please update Sample Tests also.
Ok thanks.
I've republished it following your suggestions.
There exist some 64-bit platforms where
int
has 64 bits (ILP64 models). But my main concern is that there is a discrepancy between the description (where the function is defined asuint32_t one_at_a_time(int8_t *key, uint32_t len)
and test code (where the prototype is defined asextern unsigned int jenkins_hash(char *, unsigned int)
). I think it is better to be consistent.int8_t
makes sense - because of simmetry with the test definition.But why is
uint32_t
preferred?Is there any 64bit platform where
unsigned int
is not 4 bytes long?Thank you.
Please also change the function signature in Sample Tests:
extern uint32_t jenkins_hash(int8_t *, uint32_t);
(and don't forget to include<stdint.h>
).Indeed, I agree with you, reason why I didn't raise this as an issue.
I was sure the C standard defines the default signedness (to signed), but I was wrong.
Thanks, changed to
int8_t
.I've addressed both issues and re-published. Thanks.
Loading more items...