1 /* Copyright Massachusetts Institute of Technology 1985 */
2 /* Copyright (C) 2002, 2003, 2004, 2005,
3 2006 Free Software Foundation, Inc. */
6 Permission to use, copy, modify, distribute, and sell this software and its
7 documentation for any purpose is hereby granted without fee, provided that
8 the above copyright notice appear in all copies and that both that
9 copyright notice and this permission notice appear in supporting
10 documentation, and that the name of M.I.T. not be used in advertising or
11 publicity pertaining to distribution of the software without specific,
12 written prior permission. M.I.T. makes no representations about the
13 suitability of this software for any purpose. It is provided "as is"
14 without express or implied warranty.
29 * XCreateAssocTable - Create an XAssocTable. The size argument should be
30 * a power of two for efficiency reasons. Some size suggestions: use 32
31 * buckets per 100 objects; a reasonable maximum number of object per
32 * buckets is 8. If there is an error creating the XAssocTable, a NULL
33 * pointer is returned.
35 XAssocTable
*XCreateAssocTable(size
)
36 register int size
; /* Desired size of the table. */
38 register XAssocTable
*table
; /* XAssocTable to be initialized. */
39 register XAssoc
*buckets
; /* Pointer to the first bucket in */
40 /* the bucket array. */
42 /* Malloc the XAssocTable. */
43 if ((table
= (XAssocTable
*)malloc(sizeof(XAssocTable
))) == NULL
) {
44 /* malloc call failed! */
49 /* calloc the buckets (actually just their headers). */
50 buckets
= (XAssoc
*)calloc((unsigned)size
, (unsigned)sizeof(XAssoc
));
51 if (buckets
== NULL
) {
52 /* calloc call failed! */
57 /* Insert table data into the XAssocTable structure. */
58 table
->buckets
= buckets
;
62 /* Initialize each bucket. */
63 buckets
->prev
= buckets
;
64 buckets
->next
= buckets
;
71 /* arch-tag: 5df3237d-ada0-4345-a3ab-282cafb397aa
72 (do not change this comment) */