aboutsummaryrefslogtreecommitdiff
path: root/src/stream.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/stream.cpp')
-rw-r--r--src/stream.cpp16
1 files changed, 16 insertions, 0 deletions
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);