Changeset View
Changeset View
Standalone View
Standalone View
src/crypto/common.h
| Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static inline uint64_t ReadBE64(const uint8_t *ptr) { | static inline uint64_t ReadBE64(const uint8_t *ptr) { | ||||
| uint64_t x; | uint64_t x; | ||||
| memcpy((char *)&x, ptr, 8); | memcpy((char *)&x, ptr, 8); | ||||
| return be64toh_internal(x); | return be64toh_internal(x); | ||||
| } | } | ||||
| static inline void WriteBE16(uint8_t *ptr, uint16_t x) { | |||||
| uint16_t v = htobe16_internal(x); | |||||
| memcpy(ptr, &v, 2); | |||||
Fabien: you don't need the (char *) cast ? | |||||
| } | |||||
| static inline void WriteBE32(uint8_t *ptr, uint32_t x) { | static inline void WriteBE32(uint8_t *ptr, uint32_t x) { | ||||
| uint32_t v = htobe32_internal(x); | uint32_t v = htobe32_internal(x); | ||||
| memcpy(ptr, (char *)&v, 4); | memcpy(ptr, (char *)&v, 4); | ||||
| } | } | ||||
| static inline void WriteBE64(uint8_t *ptr, uint64_t x) { | static inline void WriteBE64(uint8_t *ptr, uint64_t x) { | ||||
| uint64_t v = htobe64_internal(x); | uint64_t v = htobe64_internal(x); | ||||
| memcpy(ptr, (char *)&v, 8); | memcpy(ptr, (char *)&v, 8); | ||||
| } | } | ||||
| #endif // BITCOIN_CRYPTO_COMMON_H | #endif // BITCOIN_CRYPTO_COMMON_H | ||||
you don't need the (char *) cast ?