From ef1546775799fef1778074d90b9c9af51bad8fb3 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 26 Jan 2020 18:14:03 +0100 Subject: [PATCH 1/3] PacketDumper: remove unused types --- src/PacketDumper.h | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/PacketDumper.h b/src/PacketDumper.h index 78469b3d7c..38a31b920d 100644 --- a/src/PacketDumper.h +++ b/src/PacketDumper.h @@ -2,9 +2,6 @@ #pragma once -#include -#include - #include class PacketDumper { @@ -20,18 +17,3 @@ protected: void SortTimeStamp(struct timeval* timestamp); }; - -struct IP_ID { - uint32_t ip, id; -}; - -struct ltipid { - bool operator()(IP_ID id1, IP_ID id2) const - { - return id1.ip != id2.ip ? (id1.ip < id2.ip) : - (id1.id < id2.id); - } -}; - -typedef std::set IP_IDSet; -uint16_t NextIP_ID(const uint32_t src_addr, const uint16_t id); From 61c3be8e16d0b819c3c7dd545fa5540ee92be225 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 27 Jan 2020 08:50:54 +0100 Subject: [PATCH 2/3] SerializationFormat: move realloc() call out of the loop Reallocate and copy the data only once. --- src/SerializationFormat.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SerializationFormat.cc b/src/SerializationFormat.cc index 1a572bd923..debb999b26 100644 --- a/src/SerializationFormat.cc +++ b/src/SerializationFormat.cc @@ -81,8 +81,8 @@ bool SerializationFormat::WriteData(const void* b, size_t count) while ( output_pos + count > output_size ) { output_size *= GROWTH_FACTOR; - output = (char*)safe_realloc(output, output_size); } + output = (char*)safe_realloc(output, output_size); memcpy(output + output_pos, b, count); output_pos += count; From 662c3aab5855e21569a862b5016f1b60b3027f52 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 27 Jan 2020 08:56:47 +0100 Subject: [PATCH 3/3] Desc: move realloc() call out of the loop --- src/Desc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Desc.cc b/src/Desc.cc index 3238248750..6d997ff004 100644 --- a/src/Desc.cc +++ b/src/Desc.cc @@ -378,8 +378,8 @@ void ODesc::Grow(unsigned int n) while ( offset + n + SLOP >= size ) { size *= 2; - base = safe_realloc(base, size); } + base = safe_realloc(base, size); } void ODesc::Clear()