[cvs] bogofilter wordhash.c,1.9,1.10 wordhash.h,1.6,1.7
Fast Bayesian spam filter along lines suggested by Paul Graham
Brought to you by:
m-a
From: <re...@us...> - 2002-10-31 13:15:59
|
Update of /cvsroot/bogofilter/bogofilter In directory usw-pr-cvs1:/tmp/cvs-serv9620 Modified Files: wordhash.c wordhash.h Log Message: Put alignment/offset of code in smalloc() routine. As the calculations are all done at compile time, there is no speed penalty. Index: wordhash.c =================================================================== RCS file: /cvsroot/bogofilter/bogofilter/wordhash.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** wordhash.c 29 Oct 2002 04:15:11 -0000 1.9 --- wordhash.c 31 Oct 2002 13:15:55 -0000 1.10 *************** *** 46,59 **** { int i; - - /*used to determine alignment requirements */ - struct dummy { char *c; int i; }; wordhash_t *h = xmalloc (sizeof (wordhash_t)); h->bin = xmalloc (NHASH * sizeof (hashnode_t **)); ! ! h->alignment = offsetof(struct dummy, i); ! for (i = 0; i < NHASH; i++) h->bin[i] = NULL; --- 46,54 ---- { int i; wordhash_t *h = xmalloc (sizeof (wordhash_t)); h->bin = xmalloc (NHASH * sizeof (hashnode_t **)); ! for (i = 0; i < NHASH; i++) h->bin[i] = NULL; *************** *** 122,127 **** char *t; /* Force alignment on architecture's natural boundary.*/ ! n += h->alignment - ( n % h->alignment); if (x == NULL || x->avail < n) --- 117,126 ---- char *t; + /* determine architecture's alignment boundary */ + struct dummy { char *c; int i; }; + size_t alignment= offsetof(struct dummy, i); + /* Force alignment on architecture's natural boundary.*/ ! n += alignment - ( n % alignment); if (x == NULL || x->avail < n) Index: wordhash.h =================================================================== RCS file: /cvsroot/bogofilter/bogofilter/wordhash.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** wordhash.h 29 Oct 2002 03:51:17 -0000 1.6 --- wordhash.h 31 Oct 2002 13:15:56 -0000 1.7 *************** *** 31,36 **** wh_alloc_str *strings; /* list of string buffers */ - size_t alignment; /* Architecture's alignment boundary */ - hashnode_t *iter_ptr; hashnode_t *iter_head; --- 31,34 ---- |