Changeset 5eeba76


Ignore:
Timestamp:
05/04/06 17:05:13 (15 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
bc4c11e
Parents:
48a20e3
Message:

Fixed memory leak in trace_event_trace
Wrote an example using the event framework
Removed old event examples
Updated format_pcapfile to use libtrace_direction_t
erf_read_packet now checks that malloc()ing a buffer actually succeeds

Files:
1 added
2 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • examples/event/Makefile

    r7e9d51c r5eeba76  
    11
    2 PREFIX=/usr/local
     2PREFIX=/usr/local/
    33CC=gcc
    44
     
    99LDLIBS  = -ltrace
    1010
    11 BINS = rate rate-tracetime
     11BINS = event_example
    1212.PHONY: all clean distclean install depend
    1313
  • lib/format_erf.c

    r431548c5 r5eeba76  
    530530                packet->buffer = malloc(LIBTRACE_PACKET_BUFSIZE);
    531531                packet->buf_control = TRACE_CTRL_PACKET;
    532         }
    533 
     532                if (!packet->buffer) {
     533                        trace_set_err(libtrace, errno,
     534                                        "Cannot allocate memory");
     535                        return -1;
     536                }
     537        }
     538
     539       
     540       
    534541        packet->header = packet->buffer;
    535542        packet->type = RT_DATA_ERF;
  • lib/format_helper.c

    rb333d68 r5eeba76  
    140140        /* TODO: finalise packet */
    141141        *packet = *trace->event.packet;
    142         trace->event.packet = NULL;
     142        trace_destroy_packet(&trace->event.packet);
    143143
    144144        event.type = TRACE_EVENT_PACKET;
  • lib/format_pcapfile.c

    re6d963c r5eeba76  
    216216}
    217217
    218 static int8_t pcapfile_get_direction(const libtrace_packet_t *packet)
    219 {
    220         int8_t direction  = -1;
     218static libtrace_direction_t pcapfile_get_direction(const libtrace_packet_t *packet)
     219{
     220        libtrace_direction_t direction  = -1;
    221221        switch(pcapfile_get_link_type(packet)) {
    222222                case TRACE_TYPE_LINUX_SLL:
     
    242242                         */
    243243                        if (ntohs(sll->pkttype == 0)) {
    244                                 direction = 1;
     244                                direction = TRACE_DIR_INCOMING;
    245245                        } else {
    246                                 direction = 0;
     246                                direction = TRACE_DIR_OUTGOING;
    247247                        }
    248248                        break;
     
    262262                        if (ntohs(pflog->dir==0)) {
    263263
    264                                 direction = 1;
     264                                direction = TRACE_DIR_INCOMING;
    265265                        }
    266266                        else {
    267                                 direction = 0;
     267                                direction = TRACE_DIR_OUTGOING;
    268268                        }
    269269                        break;
Note: See TracChangeset for help on using the changeset viewer.