1/* 2 * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994, 1995, 1996 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that: (1) source code distributions 7 * retain the above copyright notice and this paragraph in its entirety, (2) 8 * distributions including binary code include the above copyright notice and --- 138 unchanged lines hidden (view full) --- 147static inline struct slist *this_op(struct slist *); 148static void opt_not(struct block *); 149static void opt_peep(struct block *); 150static void opt_stmt(struct stmt *, int[], int); 151static void deadstmt(struct stmt *, struct stmt *[]); 152static void opt_deadstores(struct block *); 153static struct block *fold_edge(struct block *, struct edge *); 154static inline int eq_blk(struct block *, struct block *); |
155static u_int slength(struct slist *); |
156static int count_blocks(struct block *); 157static void number_blks_r(struct block *); |
158static u_int count_stmts(struct block *); |
159static int convert_code_r(struct block *); 160#ifdef BDEBUG 161static void opt_dump(struct block *); 162#endif 163 164static int n_blocks; 165struct block **blocks; 166static int n_edges; --- 1732 unchanged lines hidden (view full) --- 1899 free((void *)space); 1900 free((void *)levels); 1901 free((void *)blocks); 1902} 1903 1904/* 1905 * Return the number of stmts in 's'. 1906 */ |
1907static u_int |
1908slength(s) 1909 struct slist *s; 1910{ |
1911 u_int n = 0; |
1912 1913 for (; s; s = s->next) 1914 if (s->s.code != NOP) 1915 ++n; 1916 return n; 1917} 1918 1919/* --- 45 unchanged lines hidden (view full) --- 1965 * statements in the false branch from 'p' (count_stmts(JF(p))); 1966 * 1967 * the conditional jump itself (1); 1968 * 1969 * an extra long jump if the true branch requires it (p->longjt); 1970 * 1971 * an extra long jump if the false branch requires it (p->longjf). 1972 */ |
1973static u_int |
1974count_stmts(p) 1975 struct block *p; 1976{ |
1977 u_int n; |
1978 1979 if (p == 0 || isMarked(p)) 1980 return 0; 1981 Mark(p); 1982 n = count_stmts(JT(p)) + count_stmts(JF(p)); 1983 return slength(p->stmts) + n + 1 + p->longjt + p->longjf; 1984} 1985 --- 272 unchanged lines hidden (view full) --- 2258 * a program calls fopen() without ever calling fclose() on the FILE *, 2259 * it will leak the FILE structure; the leak is not in fopen(), it's in 2260 * the program.) Change the program to use pcap_freecode() when it's 2261 * done with the filter program. See the pcap man page. 2262 */ 2263struct bpf_insn * 2264icode_to_fcode(root, lenp) 2265 struct block *root; |
2266 u_int *lenp; |
2267{ |
2268 u_int n; |
2269 struct bpf_insn *fp; 2270 2271 /* 2272 * Loop doing convert_code_r() until no branches remain 2273 * with too-large offsets. 2274 */ 2275 while (1) { 2276 unMarkAll(); --- 71 unchanged lines hidden --- |