Replace padlength tables with inline functions from misc.h

Adds new function padding_for_int32() and uses existing pad_to_int32()
depending on required results.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
Alan Coopersmith
2012-07-09 19:12:44 -07:00
committed by Keith Packard
parent 2b1c1300cc
commit ad4092cf7d
5 changed files with 50 additions and 13 deletions

View File

@@ -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);