Revert "DynamicBuffer: implement BDataIO"

This reverts commit 36b1f55a18.
This commit is contained in:
Ingo Weinhold 2014-06-18 21:39:34 +02:00
parent 256080b112
commit 747b401e87
3 changed files with 13 additions and 14 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2009-2014, Haiku, Inc. All Rights Reserved.
* Copyright 2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -9,11 +9,10 @@
#ifndef _DYNAMIC_BUFFER_H
#define _DYNAMIC_BUFFER_H
#include <DataIO.h>
#include <SupportDefs.h>
class DynamicBuffer : public BDataIO {
class DynamicBuffer {
public:
DynamicBuffer(size_t initialSize = 0);
~DynamicBuffer();
@ -26,11 +25,11 @@ public:
// Insert data at the end of the buffer. The buffer will be increased to
// accomodate the data if needed.
status_t Write(const void* data, size_t size);
status_t Insert(const void* data, size_t size);
// Remove data from the start of the buffer. Move the buffer start
// pointer to point to the data following it.
ssize_t Read(void* data, size_t size);
status_t Remove(void* data, size_t size);
// Return a pointer to the underlying buffer. Note this will not
// necessarily be a pointer to the start of the allocated memory as the

View File

@ -68,7 +68,7 @@ DynamicBuffer::InitCheck() const
status_t
DynamicBuffer::Write(const void* data, size_t size)
DynamicBuffer::Insert(const void* data, size_t size)
{
if (fInit != B_OK)
return fInit;
@ -84,14 +84,14 @@ DynamicBuffer::Write(const void* data, size_t size)
}
ssize_t
DynamicBuffer::Read(void* data, size_t size)
status_t
DynamicBuffer::Remove(void* data, size_t size)
{
if (fInit != B_OK)
return fInit;
if (size > Size())
size = Size();
if (fDataStart + size > fDataEnd)
return B_BUFFER_OVERFLOW;
memcpy(data, fBuffer + fDataStart, size);
fDataStart += size;
@ -99,7 +99,7 @@ DynamicBuffer::Read(void* data, size_t size)
if (fDataStart == fDataEnd)
fDataStart = fDataEnd = 0;
return size;
return B_OK;
}

View File

@ -54,7 +54,7 @@ BNetBuffer::BNetBuffer(BMessage* archive) :
&bufferSize) == B_OK) {
fImpl = new (std::nothrow) DynamicBuffer(bufferSize);
if (fImpl != NULL) {
status_t result = fImpl->Write(bufferPtr, bufferSize);
status_t result = fImpl->Insert(bufferPtr, bufferSize);
if (result == B_OK)
fInit = fImpl->InitCheck();
else
@ -185,7 +185,7 @@ BNetBuffer::AppendString(const char* data)
status_t
BNetBuffer::AppendData(const void* data, size_t size)
{
return fImpl->Write(data, size);
return fImpl->Insert(data, size);
}
@ -332,7 +332,7 @@ BNetBuffer::RemoveString(char* data, size_t size)
status_t
BNetBuffer::RemoveData(void* data, size_t size)
{
return fImpl->Read(data, size);
return fImpl->Remove(data, size);
}