summaryrefslogtreecommitdiff
path: root/include/misc.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/misc.h')
-rw-r--r--include/misc.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/misc.h b/include/misc.h
index 6bea82f33..7f7f221a8 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -232,6 +232,20 @@ pad_to_int32(const int bytes)
return (((bytes) + 3) & ~3);
}
+/**
+ * Calculate padding needed to bring the number of bytes to an even
+ * multiple of 4.
+ * @param bytes The minimum number of bytes needed.
+ * @return The bytes of padding needed to arrive at the closest multiple of 4
+ * that is equal or higher than bytes.
+ */
+static inline int
+padding_for_int32(const int bytes)
+{
+ return ((-bytes) & 3);
+}
+
+
extern char **xstrtokenize(const char *str, const char *separators);
extern void FormatUInt64(uint64_t num, char *string);
extern void FormatUInt64Hex(uint64_t num, char *string);