From d64d49d00402ffb7b90dcd1a9a6b808247609a15 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 6 Jul 2015 17:15:27 -0700 Subject: [PATCH] remove PacketByteArray from networking --- libraries/networking/src/PacketByteArray.cpp | 60 -------------------- 1 file changed, 60 deletions(-) delete mode 100644 libraries/networking/src/PacketByteArray.cpp diff --git a/libraries/networking/src/PacketByteArray.cpp b/libraries/networking/src/PacketByteArray.cpp deleted file mode 100644 index 4d456b9066..0000000000 --- a/libraries/networking/src/PacketByteArray.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// -// PacketPayload.cpp -// libraries/networking/src -// -// Created by Stephen Birarda on 07/06/15. -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include "PacketPayload.h" - -PacketPayload::PacketPayload(char* data, int maxBytes) : - _data(data) - _maxBytes(maxBytes) -{ - -} - -int PacketPayload::append(const char* src, int srcBytes) { - // this is a call to write at the current index - int numWrittenBytes = write(src, srcBytes, _index); - - if (numWrittenBytes > 0) { - // we wrote some bytes, push the index - _index += numWrittenBytes; - return numWrittenBytes; - } else { - return numWrittenBytes; - } -} - -const int PACKET_WRITE_ERROR = -1; - -int PacketPayload::write(const char* src, int srcBytes, int index) { - if (index >= _maxBytes) { - // we were passed a bad index, return -1 - return PACKET_WRITE_ERROR; - } - - // make sure we have the space required to write this block - int bytesAvailable = _maxBytes - index; - - if (bytesAvailable < srcBytes) { - // good to go - write the data - memcpy(_data + index, src, srcBytes); - - // should this cause us to push our index (is this the farthest we've written in data)? - _index = std::max(_data + index + srcBytes, _index); - - // return the number of bytes written - return srcBytes; - } else { - // not enough space left for this write - return an error - return PACKET_WRITE_ERROR; - } -} - -