Helper function for appending more memory to a memory_c

This commit is contained in:
Moritz Bunkus 2011-09-18 13:14:23 +02:00
parent 87ee67fc50
commit 36e77f8468
2 changed files with 15 additions and 0 deletions

View File

@ -34,6 +34,17 @@ memory_c::resize(size_t new_size) throw() {
}
}
void
memory_c::add(unsigned char *new_buffer,
size_t new_size) {
if ((0 == new_size) || (NULL == new_buffer))
return;
size_t previous_size = get_size();
resize(previous_size + new_size);
memcpy(get_buffer() + previous_size, new_buffer, new_size);
}
memory_cptr
lace_memory_xiph(const std::vector<memory_cptr> &blocks) {
size_t i, size = 1;

View File

@ -138,6 +138,10 @@ public:
}
void resize(size_t new_size) throw();
void add(unsigned char *new_buffer, size_t new_size);
void add(memory_cptr &new_buffer) {
add(new_buffer->get_buffer(), new_buffer->get_size());
}
operator const unsigned char *() const {
return its_counter ? its_counter->ptr : NULL;