summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-03-12 12:43:30 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-03-12 12:43:30 +0100
commit87ecf290f471b9624a00442958a4cd74eead4dc8 (patch)
treeab8e1487c1685b557f526b00b162b8988f0d020a /AK
parent9858be636f4f3ad94b0551cf840adb7dd0d5538f (diff)
downloadserenity-87ecf290f471b9624a00442958a4cd74eead4dc8.zip
Kernel: More work on the ICMP and IPv4 support.
Diffstat (limited to 'AK')
-rw-r--r--AK/Buffer.h9
-rw-r--r--AK/ByteBuffer.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/AK/Buffer.h b/AK/Buffer.h
index 25bd4d00da..1d6f9dc5e1 100644
--- a/AK/Buffer.h
+++ b/AK/Buffer.h
@@ -12,6 +12,7 @@ template<typename T>
class Buffer : public Retainable<Buffer<T>> {
public:
static Retained<Buffer> create_uninitialized(ssize_t count);
+ static Retained<Buffer> create_zeroed(ssize_t count);
static Retained<Buffer> copy(const T*, ssize_t count);
static Retained<Buffer> wrap(T*, ssize_t count);
static Retained<Buffer> adopt(T*, ssize_t count);
@@ -111,6 +112,14 @@ inline Retained<Buffer<T>> Buffer<T>::create_uninitialized(ssize_t size)
}
template<typename T>
+inline Retained<Buffer<T>> Buffer<T>::create_zeroed(ssize_t size)
+{
+ auto buffer = ::adopt(*new Buffer<T>(size));
+ memset(buffer->pointer(), 0, size);
+ return buffer;
+}
+
+template<typename T>
inline Retained<Buffer<T>> Buffer<T>::copy(const T* elements, ssize_t size)
{
return ::adopt(*new Buffer<T>(elements, size, Copy));
diff --git a/AK/ByteBuffer.h b/AK/ByteBuffer.h
index e0e53d3ac5..ca44e58d99 100644
--- a/AK/ByteBuffer.h
+++ b/AK/ByteBuffer.h
@@ -31,6 +31,7 @@ public:
}
static ByteBuffer create_uninitialized(ssize_t size) { return ByteBuffer(Buffer<byte>::create_uninitialized(size)); }
+ static ByteBuffer create_zeroed(ssize_t size) { return ByteBuffer(Buffer<byte>::create_zeroed(size)); }
static ByteBuffer copy(const byte* data, ssize_t size) { return ByteBuffer(Buffer<byte>::copy(data, size)); }
static ByteBuffer wrap(byte* data, ssize_t size) { return ByteBuffer(Buffer<byte>::wrap(data, size)); }
static ByteBuffer adopt(byte* data, ssize_t size) { return ByteBuffer(Buffer<byte>::adopt(data, size)); }