aboutsummaryrefslogtreecommitdiff
path: root/src/parse-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/parse-utils.c')
-rw-r--r--src/parse-utils.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/parse-utils.c b/src/parse-utils.c
index 09059ed..9c38e1e 100644
--- a/src/parse-utils.c
+++ b/src/parse-utils.c
@@ -11,6 +11,7 @@
#include "event-utils.h"
#include "event-parse.h"
+#include "kbuffer.h"
#define __weak __attribute__((weak))
@@ -122,3 +123,29 @@ void __weak __vpr_stat(const char *fmt, va_list ap)
}
void vpr_stat(const char *fmt, va_list ap) __attribute__((weak, alias("__vpr_stat")));
+
+/**
+ * tep_kbuffer - return an allocated kbuffer that can be used for the tep handle
+ * @tep: the handle that will work with the kbuffer descriptor
+ *
+ * Allocates and returns a new kbuffer.
+ * The return must be freed by kbuffer_free();
+ */
+struct kbuffer *tep_kbuffer(struct tep_handle *tep)
+{
+ enum kbuffer_endian endian;
+ int long_size;
+
+ long_size = tep_get_long_size(tep);
+ if (long_size == 8)
+ long_size = KBUFFER_LSIZE_8;
+ else
+ long_size = KBUFFER_LSIZE_4;
+
+ if (tep_is_file_bigendian(tep))
+ endian = KBUFFER_ENDIAN_BIG;
+ else
+ endian = KBUFFER_ENDIAN_LITTLE;
+
+ return kbuffer_alloc(long_size, endian);
+}