View | Details | Raw Unified | Return to bug 1358
Collapse All | Expand All

(-)a/src/network/model/packet-metadata.cc (-3 / +3 lines)
 Lines 612-622    Link Here 
612
PacketMetadata::Allocate (uint32_t n)
612
PacketMetadata::Allocate (uint32_t n)
613
{
613
{
614
  uint32_t size = sizeof (struct Data);
614
  uint32_t size = sizeof (struct Data);
615
  if (n <= 10)
615
  if (n <= PACKET_METADATA_DATA_M_DATA_SIZE)
616
    {
616
    {
617
      n = 10;
617
      n = PACKET_METADATA_DATA_M_DATA_SIZE;
618
    }
618
    }
619
  size += n - 10;
619
  size += n - PACKET_METADATA_DATA_M_DATA_SIZE;
620
  uint8_t *buf = new uint8_t [size];
620
  uint8_t *buf = new uint8_t [size];
621
  struct PacketMetadata::Data *data = (struct PacketMetadata::Data *)buf;
621
  struct PacketMetadata::Data *data = (struct PacketMetadata::Data *)buf;
622
  data->m_size = n;
622
  data->m_size = n;
(-)a/src/network/model/packet-metadata.h (-2 / +11 lines)
 Lines 22-27    Link Here 
22
22
23
#include <stdint.h>
23
#include <stdint.h>
24
#include <vector>
24
#include <vector>
25
#include <limits>
25
#include "ns3/callback.h"
26
#include "ns3/callback.h"
26
#include "ns3/assert.h"
27
#include "ns3/assert.h"
27
#include "ns3/type-id.h"
28
#include "ns3/type-id.h"
 Lines 208-223    Link Here 
208
                                  const uint8_t* start,
209
                                  const uint8_t* start,
209
                                  const uint8_t* current,
210
                                  const uint8_t* current,
210
                                  uint32_t maxSize);
211
                                  uint32_t maxSize);
212
213
  /**
214
   * the size of PacketMetadata::Data::m_data such that the total size
215
   * of PacketMetadata::Data is 16 bytes
216
   */ 
217
#define PACKET_METADATA_DATA_M_DATA_SIZE 8
218
  
211
  struct Data {
219
  struct Data {
212
    /* number of references to this struct Data instance. */
220
    /* number of references to this struct Data instance. */
213
    uint16_t m_count;
221
    uint32_t m_count;
214
    /* size (in bytes) of m_data buffer below */
222
    /* size (in bytes) of m_data buffer below */
215
    uint16_t m_size;
223
    uint16_t m_size;
216
    /* max of the m_used field over all objects which 
224
    /* max of the m_used field over all objects which 
217
     * reference this struct Data instance */
225
     * reference this struct Data instance */
218
    uint16_t m_dirtyEnd;
226
    uint16_t m_dirtyEnd;
219
    /* variable-sized buffer of bytes */
227
    /* variable-sized buffer of bytes */
220
    uint8_t m_data[10];
228
    uint8_t m_data[PACKET_METADATA_DATA_M_DATA_SIZE]; 
221
  };
229
  };
222
  /* Note that since the next and prev fields are 16 bit integers
230
  /* Note that since the next and prev fields are 16 bit integers
223
     and since the value 0xffff is reserved to identify the 
231
     and since the value 0xffff is reserved to identify the 
 Lines 376-381    Link Here 
376
    m_packetUid (o.m_packetUid)
384
    m_packetUid (o.m_packetUid)
377
{
385
{
378
  NS_ASSERT (m_data != 0);
386
  NS_ASSERT (m_data != 0);
387
  NS_ASSERT (m_data->m_count < std::numeric_limits<uint32_t>::max());
379
  m_data->m_count++;
388
  m_data->m_count++;
380
}
389
}
381
PacketMetadata &
390
PacketMetadata &

Return to bug 1358