Add cast to malloc to calm cc when system headers decalre int malloc()
[p5sagit/p5-mst-13.2.git] / ext / SDBM_File / sdbm / util.c
1 #include <stdio.h>
2 #ifdef SDBM
3 #include "sdbm.h"
4 #else
5 #include "ndbm.h"
6 #endif
7
8 void
9 oops(s1, s2)
10 register char *s1;
11 register char *s2;
12 {
13         extern int errno, sys_nerr;
14         extern char *sys_errlist[];
15         extern char *progname;
16
17         if (progname)
18                 fprintf(stderr, "%s: ", progname);
19         fprintf(stderr, s1, s2);
20         if (errno > 0 && errno < sys_nerr)
21                 fprintf(stderr, " (%s)", sys_errlist[errno]);
22         fprintf(stderr, "\n");
23         exit(1);
24 }
25
26 int
27 okpage(pag)
28 char *pag;
29 {
30         register unsigned n;
31         register off;
32         register short *ino = (short *) pag;
33
34         if ((n = ino[0]) > PBLKSIZ / sizeof(short))
35                 return 0;
36
37         if (!n)
38                 return 1;
39
40         off = PBLKSIZ;
41         for (ino++; n; ino += 2) {
42                 if (ino[0] > off || ino[1] > off ||
43                     ino[1] > ino[0])
44                         return 0;
45                 off = ino[1];
46                 n -= 2;
47         }
48
49         return 1;
50 }