summaryrefslogtreecommitdiff
path: root/src/lib/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/utils.c')
-rw-r--r--src/lib/utils.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/lib/utils.c b/src/lib/utils.c
index fdbcd9d9..fd275f63 100644
--- a/src/lib/utils.c
+++ b/src/lib/utils.c
@@ -27,16 +27,26 @@
#include <stdlib.h>
#include <string.h>
+int bufcmp(const buffer_t * a,
+ const buffer_t * b)
+{
+ if (a->len != b->len)
+ return a->len < b->len ? -1 : 1;
+
+ return memcmp(a->data, b->data, a->len);
+}
+
+
int n_digits(unsigned i)
{
- int n = 1;
+ int n = 1;
- while (i > 9) {
- ++n;
- i /= 10;
- }
+ while (i > 9) {
+ ++n;
+ i /= 10;
+ }
- return n;
+ return n;
}
char * path_strip(const char * src)