summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index e77f65b..96cbe11 100644
--- a/src/util.c
+++ b/src/util.c
@@ -18,6 +18,32 @@ read_uint32_le(const uint8_t *p)
return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
}
+void write_uint16_le(uint8_t *p, uint16_t v)
+{
+ p[0] = v & 0xFF;
+ p[1] = (v >> 8) & 0xFF;
+}
+
+void write_uint32_le(uint8_t *p, uint32_t v)
+{
+ p[0] = v & 0xFF;
+ p[1] = (v >> 8) & 0xFF;
+ p[2] = (v >> 16) & 0xFF;
+ p[3] = (v >> 24) & 0xFF;
+}
+
+void write_uint64_le(uint8_t *p, uint64_t v)
+{
+ p[0] = v & 0xFF;
+ p[1] = (v >> 8) & 0xFF;
+ p[2] = (v >> 16) & 0xFF;
+ p[3] = (v >> 24) & 0xFF;
+ p[4] = (v >> 32) & 0xFF;
+ p[5] = (v >> 40) & 0xFF;
+ p[6] = (v >> 48) & 0xFF;
+ p[7] = (v >> 56) & 0xFF;
+}
+
int
memcmp(const void *p1, const void *p2, size_t n)
{
@@ -31,3 +57,11 @@ memcmp(const void *p1, const void *p2, size_t n)
}
return 0;
}
+
+void
+memset(void *v, uint8_t b, size_t n)
+{
+ uint8_t *p = v;
+ for(size_t i = 0; i < n; i++)
+ p[i] = b;
+}