From ab7817db03c8e180b42f62dbcb48fd65354c12d0 Mon Sep 17 00:00:00 2001 From: Andrea Zoli <zoli@iasfbo.inaf.it> Date: Thu, 26 Jun 2014 13:22:39 +0200 Subject: [PATCH] Fix ByteStream and Packet initialization. --- include/ByteStream.h | 5 +++-- include/Packet.h | 5 +++-- src/ByteStream.cpp | 22 ++++++---------------- src/Packet.cpp | 25 +++++++++++++------------ 4 files changed, 25 insertions(+), 32 deletions(-) diff --git a/include/ByteStream.h b/include/ByteStream.h index afbc92f..5d4b436 100644 --- a/include/ByteStream.h +++ b/include/ByteStream.h @@ -2,8 +2,9 @@ ByteStream.h ------------------- begin : Thu Nov 29 2001 - copyright : (C) 2001, 2013 by Andrea Bulgarelli - email : bulgarelli@iasfbo.inaf.it + copyright : (C) 2001-2013 by Andrea Bulgarelli + 2013-2014 by Andrea Bulgarelli, Andrea Zoli + email : bulgarelli@iasfbo.inaf.it, zoli@iasfbo.inaf.it ***************************************************************************/ /*************************************************************************** diff --git a/include/Packet.h b/include/Packet.h index dd08f0c..3373937 100644 --- a/include/Packet.h +++ b/include/Packet.h @@ -2,8 +2,9 @@ Packet.h - description ------------------- begin : Thu Nov 29 2001 - copyright : (C) 2001, 2013 by Andrea Bulgarelli - email : bulgarelli@iasfbo.inaf.it + copyright : (C) 2001-2013 by Andrea Bulgarelli + 2013-2014 by Andrea Bulgarelli, Andrea Zoli + email : bulgarelli@iasfbo.inaf.it, zoli@iasfbo.inaf.it ***************************************************************************/ /*************************************************************************** diff --git a/src/ByteStream.cpp b/src/ByteStream.cpp index 7b85685..14615e6 100644 --- a/src/ByteStream.cpp +++ b/src/ByteStream.cpp @@ -2,8 +2,9 @@ ByteStream.cpp - description ------------------- begin : Thu Nov 29 2001 - copyright : (C) 2001, 2013 by Andrea Bulgarelli - email : bulgarelli@iasfbo.inaf.it + copyright : (C) 2001-2013 by Andrea Bulgarelli + 2013-2914 by Andrea Bulgarelli, Andrea Zoli + email : bulgarelli@iasfbo.inaf.it, zoli@iasfbo.inaf.it ***************************************************************************/ /*************************************************************************** @@ -30,39 +31,28 @@ using namespace PacketLib; /// In all methods of constructor or set type accepting ByteStreamPtr the swap is never applied. PacketLib::ByteStream::ByteStream(bool bigendian) + : stream(0), byteInTheStream(0), bigendian(bigendian) { mem_allocation_constructor = true; - - byteInTheStream = 0; - this->stream = 0; - this->bigendian = bigendian; - setMemoryAllocated(false); mem_allocation_constructor = false; } PacketLib::ByteStream::ByteStream(dword dim, bool bigendian) + : byteInTheStream(dim), bigendian(bigendian) { mem_allocation_constructor = true; - - byteInTheStream = dim; stream = (byte*) new byte[dim]; - /// memset(stream, 0, dim); ok - this->bigendian = bigendian; - setMemoryAllocated(true); mem_allocation_constructor = false; } PacketLib::ByteStream::ByteStream(byte* stream, dword dim, bool bigendian, bool memory_sharing) + : stream(stream), byteInTheStream(dim), bigendian(bigendian) { mem_allocation_constructor = true; - - byteInTheStream = dim; - this->stream = stream; - this->bigendian = bigendian; //if(!memory_sharing) // swapWordIfStreamIsLittleEndian(); /// \remarks memory_sharing == false means that the object is responsible for the memory diff --git a/src/Packet.cpp b/src/Packet.cpp index 564eb5e..2ffa6fe 100644 --- a/src/Packet.cpp +++ b/src/Packet.cpp @@ -2,8 +2,9 @@ Packet.cpp - description ------------------- begin : Thu Nov 29 2001 - copyright : (C) 2001, 2013 by Andrea Bulgarelli - email : bulgarelli@iasfbo.inaf.it + copyright : (C) 2001-2013 by Andrea Bulgarelli + 2013-2014 by Andrea Bulgarelli, Andrea Zoli + email : bulgarelli@iasfbo.inaf.it, zoli@iasfbo.inaf.it ***************************************************************************/ /*************************************************************************** @@ -24,24 +25,24 @@ using namespace PacketLib; #define DECODETYPE 2 Packet::Packet(bool bigendian) - : decodedPacketDataFieldHeader(false) + : prefix(0), packet(0), stream(0), packetID(0), name(0), identifiers(0), + number_of_identifiers(0), bigendian(bigendian), thereisprefix(false), + filename(0), first_output_stream_setted(false), dimPrefix(0), + dimPacketHeader(0), dimPacketDataFieldHeader(0), + dimPacketSourceDataFieldFixed(0), dimPacketTail(0), + dimPacketStartingFixedPart(0), decodedPacketHeader(false), + decodedPacketDataFieldHeader(false), decodedPacketSourceDataField(false), + decodedPacketTail(false), compressionAlgorithmsSection(0), + compressionAlgorithmsIndex(0), compressionLevelSection(0), + compressionLevelIndex(0), compressible(false) { header = (PacketHeader*) new PacketHeader(); dataField = (PacketDataField*) new PacketDataField(); - name = 0; -// tail = new PartOfPacket(); - number_of_identifier = 0; - identifiers = 0; - this->bigendian = bigendian; - /// temp tempHeader = ByteStreamPtr(new ByteStream); tempDataField = ByteStreamPtr(new ByteStream); tempDataFieldHeader = ByteStreamPtr(new ByteStream); tempPacketDataField = ByteStreamPtr(new ByteStream); tempTail = ByteStreamPtr(new ByteStream); - first_output_stream_setted = false; - compressible = false; - } -- GitLab