mirror of https://github.com/facebook/rocksdb.git
Fix deprecated use of 0/NULL in internal_repo_rocksdb/repo/util/xxhash.h + 1
Summary: `nullptr` is typesafe. `0` and `NULL` are not. In the future, only `nullptr` will be allowed. This diff helps us embrace the future _now_ in service of enabling `-Wzero-as-null-pointer-constant`. Reviewed By: palmje Differential Revision: D56650257 fbshipit-source-id: ce628fbf12ea5846bb7103455ab859c5ed7e3598
This commit is contained in:
parent
3fa2ff3046
commit
8e1bd02279
|
@ -5394,7 +5394,7 @@ static XXH_MALLOCF void* XXH_alignedMalloc(size_t s, size_t align)
|
|||
*/
|
||||
static void XXH_alignedFree(void* p)
|
||||
{
|
||||
if (p != NULL) {
|
||||
if (p != nullptr) {
|
||||
xxh_u8* ptr = (xxh_u8*)p;
|
||||
/* Get the offset byte we added in XXH_malloc. */
|
||||
xxh_u8 offset = ptr[-1];
|
||||
|
@ -5407,7 +5407,7 @@ static void XXH_alignedFree(void* p)
|
|||
XXH_PUBLIC_API XXH3_state_t* XXH3_createState(void)
|
||||
{
|
||||
XXH3_state_t* const state = (XXH3_state_t*)XXH_alignedMalloc(sizeof(XXH3_state_t), 64);
|
||||
if (state==NULL) return NULL;
|
||||
if (state==nullptr) return nullptr;
|
||||
XXH3_INITSTATE(state);
|
||||
return state;
|
||||
}
|
||||
|
@ -5457,7 +5457,7 @@ XXH3_reset_internal(XXH3_state_t* statePtr,
|
|||
XXH_PUBLIC_API XXH_errorcode
|
||||
XXH3_64bits_reset(XXH_NOESCAPE XXH3_state_t* statePtr)
|
||||
{
|
||||
if (statePtr == NULL) return XXH_ERROR;
|
||||
if (statePtr == nullptr) return XXH_ERROR;
|
||||
XXH3_reset_internal(statePtr, 0, XXH3_kSecret, XXH_SECRET_DEFAULT_SIZE);
|
||||
return XXH_OK;
|
||||
}
|
||||
|
@ -5466,9 +5466,9 @@ XXH3_64bits_reset(XXH_NOESCAPE XXH3_state_t* statePtr)
|
|||
XXH_PUBLIC_API XXH_errorcode
|
||||
XXH3_64bits_reset_withSecret(XXH_NOESCAPE XXH3_state_t* statePtr, XXH_NOESCAPE const void* secret, size_t secretSize)
|
||||
{
|
||||
if (statePtr == NULL) return XXH_ERROR;
|
||||
if (statePtr == nullptr) return XXH_ERROR;
|
||||
XXH3_reset_internal(statePtr, 0, secret, secretSize);
|
||||
if (secret == NULL) return XXH_ERROR;
|
||||
if (secret == nullptr) return XXH_ERROR;
|
||||
if (secretSize < XXH3_SECRET_SIZE_MIN) return XXH_ERROR;
|
||||
return XXH_OK;
|
||||
}
|
||||
|
@ -5477,11 +5477,11 @@ XXH3_64bits_reset_withSecret(XXH_NOESCAPE XXH3_state_t* statePtr, XXH_NOESCAPE c
|
|||
XXH_PUBLIC_API XXH_errorcode
|
||||
XXH3_64bits_reset_withSeed(XXH_NOESCAPE XXH3_state_t* statePtr, XXH64_hash_t seed)
|
||||
{
|
||||
if (statePtr == NULL) return XXH_ERROR;
|
||||
if (statePtr == nullptr) return XXH_ERROR;
|
||||
if (seed==0) return XXH3_64bits_reset(statePtr);
|
||||
if ((seed != statePtr->seed) || (statePtr->extSecret != NULL))
|
||||
if ((seed != statePtr->seed) || (statePtr->extSecret != nullptr))
|
||||
XXH3_initCustomSecret(statePtr->customSecret, seed);
|
||||
XXH3_reset_internal(statePtr, seed, NULL, XXH_SECRET_DEFAULT_SIZE);
|
||||
XXH3_reset_internal(statePtr, seed, nullptr, XXH_SECRET_DEFAULT_SIZE);
|
||||
return XXH_OK;
|
||||
}
|
||||
|
||||
|
@ -5489,8 +5489,8 @@ XXH3_64bits_reset_withSeed(XXH_NOESCAPE XXH3_state_t* statePtr, XXH64_hash_t see
|
|||
XXH_PUBLIC_API XXH_errorcode
|
||||
XXH3_64bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr, XXH_NOESCAPE const void* secret, size_t secretSize, XXH64_hash_t seed64)
|
||||
{
|
||||
if (statePtr == NULL) return XXH_ERROR;
|
||||
if (secret == NULL) return XXH_ERROR;
|
||||
if (statePtr == nullptr) return XXH_ERROR;
|
||||
if (secret == nullptr) return XXH_ERROR;
|
||||
if (secretSize < XXH3_SECRET_SIZE_MIN) return XXH_ERROR;
|
||||
XXH3_reset_internal(statePtr, seed64, secret, secretSize);
|
||||
statePtr->useSeed = 1; /* always, even if seed64==0 */
|
||||
|
@ -5538,14 +5538,14 @@ XXH3_update(XXH3_state_t* XXH_RESTRICT const state,
|
|||
XXH3_f_accumulate f_acc,
|
||||
XXH3_f_scrambleAcc f_scramble)
|
||||
{
|
||||
if (input==NULL) {
|
||||
if (input==nullptr) {
|
||||
XXH_ASSERT(len == 0)
|
||||
return XXH_OK;
|
||||
}
|
||||
|
||||
XXH_ASSERT(state != NULL)
|
||||
{ const xxh_u8* const bEnd = input + len;
|
||||
const unsigned char* const secret = (state->extSecret == NULL) ? state->customSecret : state->extSecret;
|
||||
const unsigned char* const secret = (state->extSecret == nullptr) ? state->customSecret : state->extSecret;
|
||||
#if defined(XXH3_STREAM_USE_STACK) && XXH3_STREAM_USE_STACK >= 1
|
||||
/* For some reason, gcc and MSVC seem to suffer greatly
|
||||
* when operating accumulators directly into state.
|
||||
|
@ -5693,7 +5693,7 @@ XXH3_digest_long (XXH64_hash_t* acc,
|
|||
/*! @ingroup XXH3_family */
|
||||
XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_digest (XXH_NOESCAPE const XXH3_state_t* state)
|
||||
{
|
||||
const unsigned char* const secret = (state->extSecret == NULL) ? state->customSecret : state->extSecret;
|
||||
const unsigned char* const secret = (state->extSecret == nullptr) ? state->customSecret : state->extSecret;
|
||||
if (state->totalLen > XXH3_MIDSIZE_MAX) {
|
||||
XXH_ALIGN(XXH_ACC_ALIGN) XXH64_hash_t acc[XXH_ACC_NB];
|
||||
XXH3_digest_long(acc, state, secret);
|
||||
|
@ -6131,7 +6131,7 @@ XXH_PUBLIC_API XXH128_hash_t
|
|||
XXH3_128bits_withSecretandSeed(XXH_NOESCAPE const void* input, size_t len, XXH_NOESCAPE const void* secret, size_t secretSize, XXH64_hash_t seed)
|
||||
{
|
||||
if (len <= XXH3_MIDSIZE_MAX)
|
||||
return XXH3_128bits_internal(input, len, seed, XXH3_kSecret, sizeof(XXH3_kSecret), NULL);
|
||||
return XXH3_128bits_internal(input, len, seed, XXH3_kSecret, sizeof(XXH3_kSecret), nullptr);
|
||||
return XXH3_hashLong_128b_withSecret(input, len, seed, secret, secretSize);
|
||||
}
|
||||
|
||||
|
@ -6189,7 +6189,7 @@ XXH3_128bits_update(XXH_NOESCAPE XXH3_state_t* state, XXH_NOESCAPE const void* i
|
|||
/*! @ingroup XXH3_family */
|
||||
XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_digest (XXH_NOESCAPE const XXH3_state_t* state)
|
||||
{
|
||||
const unsigned char* const secret = (state->extSecret == NULL) ? state->customSecret : state->extSecret;
|
||||
const unsigned char* const secret = (state->extSecret == nullptr) ? state->customSecret : state->extSecret;
|
||||
if (state->totalLen > XXH3_MIDSIZE_MAX) {
|
||||
XXH_ALIGN(XXH_ACC_ALIGN) XXH64_hash_t acc[XXH_ACC_NB];
|
||||
XXH3_digest_long(acc, state, secret);
|
||||
|
@ -6287,7 +6287,7 @@ XXH3_generateSecret(XXH_NOESCAPE void* secretBuffer, size_t secretSize, XXH_NOES
|
|||
XXH_ASSERT(secretSize >= XXH3_SECRET_SIZE_MIN)
|
||||
#else
|
||||
/* production mode, assert() are disabled */
|
||||
if (secretBuffer == NULL) return XXH_ERROR;
|
||||
if (secretBuffer == nullptr) return XXH_ERROR;
|
||||
if (secretSize < XXH3_SECRET_SIZE_MIN) return XXH_ERROR;
|
||||
#endif
|
||||
|
||||
|
@ -6298,7 +6298,7 @@ XXH3_generateSecret(XXH_NOESCAPE void* secretBuffer, size_t secretSize, XXH_NOES
|
|||
#if (XXH_DEBUGLEVEL >= 1)
|
||||
XXH_ASSERT(customSeed != NULL)
|
||||
#else
|
||||
if (customSeed == NULL) return XXH_ERROR;
|
||||
if (customSeed == nullptr) return XXH_ERROR;
|
||||
#endif
|
||||
|
||||
/* Fill secretBuffer with a copy of customSeed - repeat as needed */
|
||||
|
|
Loading…
Reference in New Issue