diff --git a/src/common/memory.cpp b/src/common/memory.cpp index a034686f3..9368e9171 100644 --- a/src/common/memory.cpp +++ b/src/common/memory.cpp @@ -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 &blocks) { size_t i, size = 1; diff --git a/src/common/memory.h b/src/common/memory.h index 2d08415cb..5f40d82c9 100644 --- a/src/common/memory.h +++ b/src/common/memory.h @@ -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;