Changeset 784


Ignore:
Timestamp:
05/04/06 17:05:13 (7 years ago)
Author:
spa1
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

Location:
trunk
Files:
1 added
2 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/event/Makefile

    r297 r784  
    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 
  • trunk/lib/format_erf.c

    r782 r784  
    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; 
  • trunk/lib/format_helper.c

    r742 r784  
    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; 
  • trunk/lib/format_pcapfile.c

    r770 r784  
    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.