1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Fix alignment padding calculation.

This commit is contained in:
DDoSolitary
2019-03-10 11:48:56 +08:00
parent 78aa7d1787
commit 2f16497bf8

View File

@@ -41,7 +41,8 @@ namespace Tins {
namespace Utils { namespace Utils {
uint32_t calculate_padding(uint32_t alignment, uint32_t offset) { uint32_t calculate_padding(uint32_t alignment, uint32_t offset) {
return offset % alignment; uint32_t extra = offset % alignment;
return extra == 0 ? 0 : alignment - extra;
} }
uint32_t get_bit(uint32_t value) { uint32_t get_bit(uint32_t value) {