Buffer: Add an append_data() method
This commit is contained in:
parent
89ad6869a4
commit
83492339ec
@ -19,6 +19,8 @@ class Buffer
|
|||||||
|
|
||||||
Result<u8*> slice(usize offset, usize size);
|
Result<u8*> slice(usize offset, usize size);
|
||||||
|
|
||||||
|
Result<void> append_data(u8* data, usize size);
|
||||||
|
|
||||||
u8* data()
|
u8* data()
|
||||||
{
|
{
|
||||||
return m_data;
|
return m_data;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include <luna/Buffer.h>
|
#include <luna/Buffer.h>
|
||||||
|
#include <luna/CString.h>
|
||||||
#include <luna/Heap.h>
|
#include <luna/Heap.h>
|
||||||
|
|
||||||
Buffer::Buffer()
|
Buffer::Buffer()
|
||||||
@ -44,3 +45,10 @@ Result<u8*> Buffer::slice(usize offset, usize size)
|
|||||||
if (offset + size > m_size) { TRY(try_resize(offset + size)); }
|
if (offset + size > m_size) { TRY(try_resize(offset + size)); }
|
||||||
return m_data + offset;
|
return m_data + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result<void> Buffer::append_data(u8* data, usize size)
|
||||||
|
{
|
||||||
|
memcpy(TRY(slice_at_end(size)), data, size);
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user