summaryrefslogtreecommitdiff
path: root/src/lib/libc/string/bm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/string/bm.c')
-rw-r--r--src/lib/libc/string/bm.c39
1 files changed, 12 insertions, 27 deletions
diff --git a/src/lib/libc/string/bm.c b/src/lib/libc/string/bm.c
index 68eac22ecc..2c4c6ca720 100644
--- a/src/lib/libc/string/bm.c
+++ b/src/lib/libc/string/bm.c
@@ -1,3 +1,4 @@
1/* $OpenBSD: bm.c,v 1.7 2007/09/02 15:19:18 deraadt Exp $ */
1/*- 2/*-
2 * Copyright (c) 1994 3 * Copyright (c) 1994
3 * The Regents of the University of California. All rights reserved. 4 * The Regents of the University of California. All rights reserved.
@@ -13,11 +14,7 @@
13 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 15 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution. 16 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software 17 * 3. Neither the name of the University nor the names of its contributors
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software 18 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission. 19 * without specific prior written permission.
23 * 20 *
@@ -34,11 +31,6 @@
34 * SUCH DAMAGE. 31 * SUCH DAMAGE.
35 */ 32 */
36 33
37#ifndef lint
38/* from: static char sccsid[] = "@(#)bm.c 8.7 (Berkeley) 6/21/94"; */
39static char *rcsid = "$Id: bm.c,v 1.1.1.1 1995/10/18 08:42:20 deraadt Exp $";
40#endif /* not lint */
41
42#include <sys/types.h> 34#include <sys/types.h>
43 35
44#include <bm.h> 36#include <bm.h>
@@ -90,14 +82,11 @@ static u_char const freq_def[256] = {
90}; 82};
91 83
92bm_pat * 84bm_pat *
93bm_comp(pb, len, freq) 85bm_comp(u_char const *pb, size_t len, u_char const *freq)
94 u_char const *pb;
95 size_t len;
96 u_char const *freq;
97{ 86{
98 register u_char const *pe, *p; 87 u_char const *pe, *p;
99 register size_t *d, r; 88 size_t *d, r;
100 register int j; 89 int j;
101 int sv_errno; 90 int sv_errno;
102 bm_pat *pat; 91 bm_pat *pat;
103 92
@@ -115,7 +104,7 @@ bm_comp(pb, len, freq)
115 goto mem; 104 goto mem;
116 memcpy(pat->pat, pb, pat->patlen); 105 memcpy(pat->pat, pb, pat->patlen);
117 /* get skip delta */ 106 /* get skip delta */
118 if ((pat->delta = malloc(256 * sizeof(*d))) == NULL) 107 if ((pat->delta = calloc(256, sizeof(*d))) == NULL)
119 goto mem; 108 goto mem;
120 for (j = 0, d = pat->delta; j < 256; j++) 109 for (j = 0, d = pat->delta; j < 256; j++)
121 d[j] = pat->patlen; 110 d[j] = pat->patlen;
@@ -147,8 +136,7 @@ mem: sv_errno = errno;
147} 136}
148 137
149void 138void
150bm_free(pat) 139bm_free(bm_pat *pat)
151 bm_pat *pat;
152{ 140{
153 if (pat->pat != NULL) 141 if (pat->pat != NULL)
154 free(pat->pat); 142 free(pat->pat);
@@ -158,14 +146,11 @@ bm_free(pat)
158} 146}
159 147
160u_char * 148u_char *
161bm_exec(pat, base, n) 149bm_exec(bm_pat *pat, u_char *base, size_t n)
162 bm_pat *pat;
163 u_char *base;
164 size_t n;
165{ 150{
166 register u_char *e, *ep, *p, *q, *s; 151 u_char *e, *ep, *p, *q, *s;
167 register size_t *d0, k, md2, n1, ro; 152 size_t *d0, k, md2, n1, ro;
168 register int rc; 153 int rc;
169 154
170 if (n == 0) 155 if (n == 0)
171 return (NULL); 156 return (NULL);