MCPcopy Create free account
hub / github.com/BYVoid/OpenCC / set_array

Method set_array

deps/darts-clone-0.32h/include/darts.h:173–177  ·  view source on GitHub ↗

set_array() calls clear() in order to free memory allocated to the old array and then sets a new array. This function is useful to set a memory- mapped array. Note that the array set by set_array() is not freed in clear() and the destructor of . set_array() can also set the size of the new array but the size is not used in search methods. So it works well even if the 2nd argument

Source from the content-addressed store, hash-verified

171 // used in search methods. So it works well even if the 2nd argument is 0 or
172 // omitted. Remember that size() and total_size() returns 0 in such a case.
173 void set_array(const void *ptr, std::size_t size = 0) {
174 clear();
175 array_ = static_cast<const unit_type *>(ptr);
176 size_ = size;
177 }
178 void copy_array(const void* ptr, std::size_t num_bytes) {
179 clear();
180 const std::size_t extra_padding = num_bytes % unit_size() == 0 ? 0 : 1;

Callers 2

NewFromFileMethod · 0.80
NewFromBufferMethod · 0.80

Calls 1

clearFunction · 0.85

Tested by

no test coverage detected