buffer: minimize memory copy in _memory_add()
Submitted by Prashant Gotarne
Link to original bug (#747959)
Description
If all the slots for the memory blocks are full, instead of merging all block to single memory block, merge only best consecutive blocks to make a room for new memory block.