]> gitweb.factorcode.org Git - factor.git/blob - vm/byte_arrays.hpp
VM: Remove unnecessary explicit keywords
[factor.git] / vm / byte_arrays.hpp
1 namespace factor {
2
3 struct growable_byte_array {
4   cell count;
5   data_root<byte_array> elements;
6
7   growable_byte_array(factor_vm* parent, cell capacity = 40)
8       : count(0), elements(parent->allot_byte_array(capacity), parent) {}
9
10   void grow_bytes(cell len);
11   void append_bytes(void* elts, cell len);
12   void append_byte_array(cell elts);
13
14   void trim();
15 };
16
17 /* Allocates memory */
18 template <typename Type>
19 byte_array* factor_vm::byte_array_from_value(Type* value) {
20   byte_array* data = allot_uninitialized_array<byte_array>(sizeof(Type));
21   memcpy(data->data<char>(), value, sizeof(Type));
22   return data;
23 }
24
25 }