Use native endianess funcs
diff --git a/mangle.c b/mangle.c
index 7aae739..28b1ed9 100644
--- a/mangle.c
+++ b/mangle.c
@@ -25,6 +25,7 @@
#include "common.h"
#include "mangle.h"
+#include <endian.h>
#include <inttypes.h>
#include <math.h>
#include <stdlib.h>
@@ -226,14 +227,14 @@
uint16_t val = *((uint16_t *) & buf[off]);
if (util_rndGet(0, 1) == 0) {
/* BE */
- val = util_ToFromBE16(val);
+ val = be16toh(val);
val += delta;
- val = util_ToFromBE16(val);
+ val = htobe16(val);
} else {
/* LE */
- val = util_ToFromLE16(val);
+ val = le16toh(val);
val += delta;
- val = util_ToFromLE16(val);
+ val = htole16(val);
}
mangle_Overwrite(buf, (uint8_t *) & val, bufSz, off, varLen);
return;
@@ -244,14 +245,14 @@
uint32_t val = *((uint32_t *) & buf[off]);
if (util_rndGet(0, 1) == 0) {
/* BE */
- val = util_ToFromBE32(val);
+ val = be32toh(val);
val += delta;
- val = util_ToFromBE32(val);
+ val = htobe32(val);
} else {
/* LE */
- val = util_ToFromLE32(val);
+ val = le32toh(val);
val += delta;
- val = util_ToFromLE32(val);
+ val = htole32(val);
}
mangle_Overwrite(buf, (uint8_t *) & val, bufSz, off, varLen);
return;
diff --git a/util.c b/util.c
index d4150d6..ab70b8b 100644
--- a/util.c
+++ b/util.c
@@ -21,7 +21,6 @@
*
*/
-#include <endian.h>
#include <fcntl.h>
#include <inttypes.h>
#include <math.h>
@@ -229,26 +228,6 @@
return (((int64_t) tv.tv_sec * 1000LL) + ((int64_t) tv.tv_usec / 1000LL));
}
-uint16_t util_ToFromBE16(uint16_t val)
-{
- return be16toh(val);
-}
-
-uint16_t util_ToFromLE16(uint16_t val)
-{
- return le16toh(val);
-}
-
-uint32_t util_ToFromBE32(uint32_t val)
-{
- return be32toh(val);
-}
-
-uint32_t util_ToFromLE32(uint32_t val)
-{
- return le32toh(val);
-}
-
uint64_t util_getUINT32(const uint8_t * buf)
{
uint32_t r;
diff --git a/util.h b/util.h
index c27fa0f..3b009e4 100644
--- a/util.h
+++ b/util.h
@@ -55,10 +55,6 @@
extern int64_t util_timeNowMillis(void);
-extern uint16_t util_ToFromBE16(uint16_t val);
-extern uint16_t util_ToFromLE16(uint16_t val);
-extern uint32_t util_ToFromBE32(uint32_t val);
-extern uint32_t util_ToFromLE32(uint32_t val);
extern uint64_t util_getUINT32(const uint8_t * buf);
extern uint64_t util_getUINT64(const uint8_t * buf);