]> gitweb.factorcode.org Git - factor.git/blob - vm/byte_arrays.hpp
vm: replace block comments /**/ with line comments //
[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   // Allocates memory
8   growable_byte_array(factor_vm* parent, cell capacity = 40)
9       : count(0), elements(parent->allot_byte_array(capacity), parent) {}
10
11   void grow_bytes(cell len);
12   void append_bytes(void* elts, cell len);
13   void append_byte_array(cell elts);
14
15   void trim();
16 };
17
18 // Allocates memory
19 template <typename Type>
20 byte_array* factor_vm::byte_array_from_value(Type* value) {
21   byte_array* data = allot_uninitialized_array<byte_array>(sizeof(Type));
22   memcpy(data->data<char>(), value, sizeof(Type));
23   return data;
24 }
25
26 }