From 710e9e8961cf5039b425e66d2042942b7e4af0c8 Mon Sep 17 00:00:00 2001 From: Determinant Date: Fri, 28 Jun 2019 15:37:22 -0400 Subject: clean up code --- src/stream.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/stream.cpp') diff --git a/src/stream.cpp b/src/stream.cpp index f5d4ac9..6b208aa 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -133,6 +133,14 @@ bytearray_t *bytearray_new_moved_from_datastream(datastream_t *_moved_src) { } } +bytearray_t *bytearray_new_copied_from_datastream(datastream_t *src) { + try { + return new bytearray_t(*src); + } catch (...) { + return nullptr; + } +} + bytearray_t *bytearray_new_from_hex(const char *hex_str) { try { return new bytearray_t(salticidae::from_hex(hex_str)); @@ -141,6 +149,14 @@ bytearray_t *bytearray_new_from_hex(const char *hex_str) { } } +bytearray_t *bytearray_new_from_bytes(const uint8_t *arr, size_t len) { + try { + return new bytearray_t(arr, arr + len); + } catch (...) { + return nullptr; + } +} + char *datastream_get_hex(datastream_t *self) { std::string tmp = self->get_hex(); auto res = (char *)malloc(tmp.length() + 1); -- cgit v1.2.3