libluna: Add release_data() overloads to Buffer and Vector
This can be used to transfer the underlying data to a String object without copying.
This commit is contained in:
parent
d363d5e915
commit
498e20561f
@ -31,6 +31,8 @@ class Buffer
|
|||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u8* release_data();
|
||||||
|
|
||||||
u8* end()
|
u8* end()
|
||||||
{
|
{
|
||||||
return m_data + m_size;
|
return m_data + m_size;
|
||||||
|
@ -134,6 +134,14 @@ template <typename T> class Vector
|
|||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
T* release_data()
|
||||||
|
{
|
||||||
|
T* data = m_data;
|
||||||
|
m_data = nullptr;
|
||||||
|
m_size = m_capacity = 0;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
Slice<T> slice()
|
Slice<T> slice()
|
||||||
{
|
{
|
||||||
return { m_data, m_size };
|
return { m_data, m_size };
|
||||||
|
Loading…
Reference in New Issue
Block a user