- Minor code formatting change in merge

* 'misc_cleanup' of https://github.com/MaxKellermann/zeek:
  Desc: move realloc() call out of the loop
  SerializationFormat: move realloc() call out of the loop
  PacketDumper: remove unused types
This commit is contained in:
Jon Siwek 2020-01-31 11:16:56 -08:00
commit e2e90ac477
3 changed files with 4 additions and 24 deletions

View file

@ -376,11 +376,10 @@ void ODesc::AddBytesRaw(const void* bytes, unsigned int n)
void ODesc::Grow(unsigned int n)
{
while ( offset + n + SLOP >= size )
{
size *= 2;
base = safe_realloc(base, size);
}
}
void ODesc::Clear()
{

View file

@ -2,9 +2,6 @@
#pragma once
#include <queue>
#include <set>
#include <pcap.h>
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_ID, ltipid> IP_IDSet;
uint16_t NextIP_ID(const uint32_t src_addr, const uint16_t id);

View file

@ -79,10 +79,9 @@ bool SerializationFormat::WriteData(const void* b, size_t count)
{
// Increase buffer if necessary.
while ( output_pos + count > output_size )
{
output_size *= GROWTH_FACTOR;
output = (char*)safe_realloc(output, output_size);
}
memcpy(output + output_pos, b, count);
output_pos += count;