diff options
Diffstat (limited to 'src/stream.cpp')
-rw-r--r-- | src/stream.cpp | 42 |
1 files changed, 15 insertions, 27 deletions
diff --git a/src/stream.cpp b/src/stream.cpp index 2fe1a11..1925419 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -8,6 +8,7 @@ uint256_t *uint256_new() { return new uint256_t(); } uint256_t *uint256_new_from_bytes(const uint8_t *arr) { return new uint256_t(arr); } +void uint256_free(const uint256_t *self) { delete self; } bool uint256_is_null(const uint256_t *self) { return self->is_null(); } bool uint256_is_eq(const uint256_t *a, const uint256_t *b) { @@ -26,6 +27,7 @@ datastream_t *datastream_new() { return new datastream_t(); } datastream_t *datastream_new_from_bytes(const uint8_t *begin, const uint8_t *end) { return new datastream_t(begin, end); } +void datastream_free(const datastream_t *self) { delete self; } void datastream_assign_by_copy(datastream_t *dst, const datastream_t *src) { *dst = *src; @@ -44,39 +46,27 @@ size_t datastream_size(const datastream_t *self) { return self->size(); } void datastream_put_u8(datastream_t *self, uint8_t val) { *self << val; } void datastream_put_u16(datastream_t *self, uint16_t val) { *self << val; } void datastream_put_u32(datastream_t *self, uint32_t val) { *self << val; } +void datastream_put_u64(datastream_t *self, uint64_t val) { *self << val; } void datastream_put_i8(datastream_t *self, int8_t val) { *self << val; } void datastream_put_i16(datastream_t *self, int16_t val) { *self << val; } void datastream_put_i32(datastream_t *self, int32_t val) { *self << val; } +void datastream_put_i64(datastream_t *self, int64_t val) { *self << val; } void datastream_put_data(datastream_t *self, const uint8_t *begin, const uint8_t *end) { self->put_data(begin, end); } -uint8_t datastream_get_u8(datastream_t *self) { - uint8_t val; *self >> val; return val; -} - -uint16_t datastream_get_u16(datastream_t *self) { - uint16_t val; *self >> val; return val; -} +uint8_t datastream_get_u8(datastream_t *self) { uint8_t val; *self >> val; return val; } +uint16_t datastream_get_u16(datastream_t *self) { uint16_t val; *self >> val; return val; } +uint32_t datastream_get_u32(datastream_t *self) { uint32_t val; *self >> val; return val; } +uint64_t datastream_get_u64(datastream_t *self) { uint64_t val; *self >> val; return val; } -uint32_t datastream_get_u32(datastream_t *self) { - uint32_t val; *self >> val; return val; -} - -int8_t datastream_get_i8(datastream_t *self) { - int8_t val; *self >> val; return val; -} - -int16_t datastream_get_i16(datastream_t *self) { - int16_t val; *self >> val; return val; -} - -int32_t datastream_get_i32(datastream_t *self) { - int32_t val; *self >> val; return val; -} +int8_t datastream_get_i8(datastream_t *self) { int8_t val; *self >> val; return val; } +int16_t datastream_get_i16(datastream_t *self) { int16_t val; *self >> val; return val; } +int32_t datastream_get_i32(datastream_t *self) { int32_t val; *self >> val; return val; } +int64_t datastream_get_i64(datastream_t *self) { int64_t val; *self >> val; return val; } const uint8_t *datastream_get_data_inplace(datastream_t *self, size_t len) { return self->get_data_inplace(len); @@ -86,11 +76,9 @@ uint256_t *datastream_get_hash(const datastream_t *self) { return new uint256_t(self->get_hash()); } -void datastream_free(const datastream_t *self) { delete self; } - -bytearray_t *datastream_to_bytearray(datastream_t *self) { - auto res = new bytearray_t(std::move(*self)); - delete self; +bytearray_t *datastream_to_bytearray(datastream_t *_moved_self) { + auto res = new bytearray_t(std::move(*_moved_self)); + delete _moved_self; return res; } |