diff options
author | Alex Auvolat <alex.auvolat@ens.fr> | 2014-12-26 12:37:30 +0100 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ens.fr> | 2014-12-26 12:37:30 +0100 |
commit | a5dfdd2b3fa91a2cda4f807c88bd35928e3c7a61 (patch) | |
tree | 86bbe5558fe35b7263bd2c7859dfb9b4cb634073 /kernel/lib/buffer.c | |
parent | 8c247352543c50204314efeb988f9f59d84f5019 (diff) | |
download | macroscope-a5dfdd2b3fa91a2cda4f807c88bd35928e3c7a61.tar.gz macroscope-a5dfdd2b3fa91a2cda4f807c88bd35928e3c7a61.zip |
Diffstat (limited to 'kernel/lib/buffer.c')
-rw-r--r-- | kernel/lib/buffer.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/kernel/lib/buffer.c b/kernel/lib/buffer.c index 4d168e0..d2f9644 100644 --- a/kernel/lib/buffer.c +++ b/kernel/lib/buffer.c @@ -91,7 +91,7 @@ size_t read_buffer(buffer_t *b, char* dest, size_t begin, size_t n) { // BUFFER CREATION FUNCTIONS // // ========================= // -buffer_t *buffer_from_bytes_nocopy(const char* data, size_t n) { +buffer_t *buffer_from_bytes_nocopy(const char* data, size_t n, bool own_bytes) { buffer_t *b = (buffer_t*)kmalloc(sizeof(buffer_t)); if (b == 0) return 0; @@ -99,7 +99,7 @@ buffer_t *buffer_from_bytes_nocopy(const char* data, size_t n) { b->type = T_BYTES; b->len = n; b->bytes.data = data; - b->bytes.owned = false; + b->bytes.owned = own_bytes; return b; } @@ -109,14 +109,12 @@ buffer_t *buffer_from_bytes(const char* data, size_t n) { memcpy(data2, data, n); - buffer_t *b = buffer_from_bytes_nocopy(data2, n); + buffer_t *b = buffer_from_bytes_nocopy(data2, n, true); if (b == 0) { kfree(data2); return 0; } - b->bytes.owned = true; - return b; } |