Browse Source

Use assignement + case instead of memcpy()

master
Frank Denis 3 years ago
parent
commit
558886fd0e
  1. 8
      src/libsodium/crypto_pwhash/argon2/argon2-core.c

8
src/libsodium/crypto_pwhash/argon2/argon2-core.c

@ -76,7 +76,7 @@ static int allocate_memory(block_region **region, uint32_t m_cost);
static int
allocate_memory(block_region **region, uint32_t m_cost)
{
void * base;
void *base;
block *memory;
size_t memory_size;
@ -99,12 +99,12 @@ allocate_memory(block_region **region, uint32_t m_cost)
-1, 0)) == MAP_FAILED) {
base = NULL; /* LCOV_EXCL_LINE */
} /* LCOV_EXCL_LINE */
memcpy(&memory, &base, sizeof memory);
memory = (block *) base;
#elif defined(HAVE_POSIX_MEMALIGN)
if ((errno = posix_memalign((void **) &base, 64, memory_size)) != 0) {
base = NULL;
}
memcpy(&memory, &base, sizeof memory);
memory = (block *) base;
#else
memory = NULL;
if (memory_size + 63 < memory_size) {
@ -113,7 +113,7 @@ allocate_memory(block_region **region, uint32_t m_cost)
} else if ((base = malloc(memory_size + 63)) != NULL) {
uint8_t *aligned = ((uint8_t *) base) + 63;
aligned -= (uintptr_t) aligned & 63;
memcpy(&memory, &aligned, sizeof memory);
memory = (block *) aligned;
}
#endif
if (base == NULL) {

Loading…
Cancel
Save