Deleted Added
full compact
25c25
< "@(#) $Header: /tcpdump/master/libpcap/optimize.c,v 1.85 2005/04/04 08:42:18 guy Exp $ (LBL)";
---
> "@(#) $Header: /tcpdump/master/libpcap/optimize.c,v 1.85.2.3 2007/09/12 21:29:45 guy Exp $ (LBL)";
627c627
< bpf_int32 a, b;
---
> bpf_u_int32 a, b;
1826c1826
< int done;
---
> int done1; /* don't shadow global */
1828c1828
< done = 1;
---
> done1 = 1;
1852c1852
< done = 0;
---
> done1 = 0;
1856c1856
< done = 0;
---
> done1 = 0;
1860c1860
< if (!done)
---
> if (!done1)
1975c1975
< blocks = (struct block **)malloc(n * sizeof(*blocks));
---
> blocks = (struct block **)calloc(n, sizeof(*blocks));
1983c1983
< edges = (struct edge **)malloc(n_edges * sizeof(*edges));
---
> edges = (struct edge **)calloc(n_edges, sizeof(*edges));
1990c1990
< levels = (struct block **)malloc(n_blocks * sizeof(*levels));
---
> levels = (struct block **)calloc(n_blocks, sizeof(*levels));
2037,2038c2037,2038
< vmap = (struct vmapinfo *)malloc(maxval * sizeof(*vmap));
< vnode_base = (struct valnode *)malloc(maxval * sizeof(*vnode_base));
---
> vmap = (struct vmapinfo *)calloc(maxval, sizeof(*vmap));
> vnode_base = (struct valnode *)calloc(maxval, sizeof(*vnode_base));
2127c2127
< char *ljerr = "%s for block-local relative jump: off=%d";
---
> const char *ljerr = "%s for block-local relative jump: off=%d";
2218a2219,2232
> *
> * This routine does *NOT* leak the memory pointed to by fp. It *must
> * not* do free(fp) before returning fp; doing so would make no sense,
> * as the BPF array pointed to by the return value of icode_to_fcode()
> * must be valid - it's being returned for use in a bpf_program structure.
> *
> * If it appears that icode_to_fcode() is leaking, the problem is that
> * the program using pcap_compile() is failing to free the memory in
> * the BPF program when it's done - the leak is in the program, not in
> * the routine that happens to be allocating the memory. (By analogy, if
> * a program calls fopen() without ever calling fclose() on the FILE *,
> * it will leak the FILE structure; the leak is not in fopen(), it's in
> * the program.) Change the program to use pcap_freecode() when it's
> * done with the filter program. See the pcap man page.