2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
15 #pragma ident "%Z%%M% %I% %E% SMI"
20 static void putl(long, FILE *);
23 whash(FILE *ft
, FILE *fa
, FILE *fb
, int nhash
, int iflong
,
24 long *ptotct
, int *phused
)
27 int hash
= 0, hused
= 0;
38 hpt
= (long *)calloc(nhash
+1, sizeof (*hpt
));
40 hfreq
= (int *)calloc(nhash
, sizeof (*hfreq
));
41 assert(hfreq
!= NULL
);
44 while (fgets(line
, 100, ft
)) {
46 sscanf(line
, "%d %ld", &k
, &point
);
49 if (iflong
) putl(-1L, fb
);
56 hpt
[hash
] = lp
+= iflong
? sizeof (long) : sizeof (int);
60 if (point
!= opoint
) {
62 putl(opoint
= point
, fb
);
64 putw((int)(opoint
= point
), fb
);
65 lp
+= iflong
? sizeof (long) : sizeof (int);
69 if (iflong
) putl(-1L, fb
);
73 fwrite(&nhash
, sizeof (nhash
), 1, fa
);
74 fwrite(&iflong
, sizeof (iflong
), 1, fa
);
75 fwrite(hpt
, sizeof (*hpt
), nhash
, fa
);
76 fwrite(hfreq
, sizeof (*hfreq
), nhash
, fa
);
82 putl(long ll
, FILE *f
)