aboutsummaryrefslogtreecommitdiff
path: root/src/stream.cpp
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2019-06-28 15:37:22 -0400
committerDeterminant <ted.sybil@gmail.com>2019-06-28 15:37:22 -0400
commit710e9e8961cf5039b425e66d2042942b7e4af0c8 (patch)
treef69db46552945e945b5603d1d254df7e77d17b26 /src/stream.cpp
parentd28bf1b0c8baec3c5ab40cfb988ff974f98da439 (diff)
clean up code
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);