Changeset 747c501


Ignore:
Timestamp:
04/27/06 00:48:42 (15 years ago)
Author:
Perry Lorier <perry@…>
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:
e641bdc
Parents:
d97bbb2
Message:

Fix some memory leaks
Add new destroy for bpf filters
Properly initialise memory for wag

Location:
lib
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • lib/format_erf.c

    re4ebf84 r747c501  
    382382
    383383static int erf_init_output(libtrace_out_t *libtrace) {
    384         libtrace->format_data = calloc(1,sizeof(struct erf_format_data_out_t));
     384        libtrace->format_data = malloc(sizeof(struct erf_format_data_out_t));
    385385
    386386        OPTIONS.erf.level = 0;
  • lib/format_pcap.c

    r91db67b r747c501  
    235235}
    236236
    237 static int pcapint_pause_input(libtrace_t *libtrace)
     237static int pcap_pause_input(libtrace_t *libtrace)
    238238{
    239239        pcap_close(INPUT.pcap);
     
    242242}
    243243
     244
    244245static int pcap_fin_input(libtrace_t *libtrace)
    245246{
     247        pcap_close(INPUT.pcap);
    246248        free(libtrace->format_data);
    247249        return 0; /* success */
     
    554556        pcapint_config_input,           /* config_input */
    555557        pcapint_start_input,            /* start_input */
    556         pcapint_pause_input,            /* pause_input */
     558        pcap_pause_input,               /* pause_input */
    557559        pcapint_init_output,            /* init_output */
    558560        NULL,                           /* config_output */
  • lib/format_wag.c

    r4315572b r747c501  
    116116static int wtf_init_input(struct libtrace_t *libtrace)
    117117{
    118         libtrace->format_data = malloc(sizeof(struct wag_format_data_t));
     118        libtrace->format_data = calloc(1,sizeof(struct wag_format_data_t));
    119119        return 0;
    120120}
     
    133133
    134134static int wtf_init_output(struct libtrace_out_t *libtrace) {
    135         libtrace->format_data = calloc(1,sizeof(struct wag_format_data_out_t));
     135        libtrace->format_data = malloc(sizeof(struct wag_format_data_out_t));
    136136
    137137        OUTPUT.file = 0;
  • lib/libtrace.h

    r7fc01569 r747c501  
    11231123DLLEXPORT int trace_bpf_filter(libtrace_filter_t *filter,
    11241124                const libtrace_packet_t *packet);
     1125
     1126/** destory of BPF filter
     1127 * @param filter        the filter opaque pointer
     1128 * Deallocate all the resources associated with a BPF filter
     1129 */
     1130DLLEXPORT void trace_destroy_bpf(libtrace_filter_t *filter);
    11251131/*@}*/
    11261132
  • lib/trace.c

    rd97bbb2 r747c501  
    922922DLLEXPORT struct libtrace_filter_t *trace_bpf_setfilter(const char *filterstring) {
    923923#if HAVE_BPF
    924         struct libtrace_filter_t *filter = (struct libtrace_filter_t*)
     924        libtrace_filter_t *filter = (struct libtrace_filter_t*)
    925925                                malloc(sizeof(struct libtrace_filter_t));
    926926        filter->filterstring = strdup(filterstring);
     
    931931        return 0;
    932932#endif
     933}
     934
     935DLLEXPORT void trace_destroy_bpf(libtrace_filter_t *filter)
     936{
     937        free(filter->filterstring);
     938        if (filter->flag)
     939                pcap_freecode(&filter->filter);
     940        free(filter);
    933941}
    934942
Note: See TracChangeset for help on using the changeset viewer.