1 /* Copyright Massachusetts Institute of Technology 1985 */
2 /* Copyright (C) 2001, 2002, 2003, 2004, 2005,
3 2006, 2007 Free Software Foundation, Inc. */
20 * XCreateAssocTable - Create an XAssocTable. The size argument should be
21 * a power of two for efficiency reasons. Some size suggestions: use 32
22 * buckets per 100 objects; a reasonable maximum number of object per
23 * buckets is 8. If there is an error creating the XAssocTable, a NULL
24 * pointer is returned.
26 XAssocTable
*XCreateAssocTable(size
)
27 register int size
; /* Desired size of the table. */
29 register XAssocTable
*table
; /* XAssocTable to be initialized. */
30 register XAssoc
*buckets
; /* Pointer to the first bucket in */
31 /* the bucket array. */
33 /* Malloc the XAssocTable. */
34 if ((table
= (XAssocTable
*)malloc(sizeof(XAssocTable
))) == NULL
) {
35 /* malloc call failed! */
40 /* calloc the buckets (actually just their headers). */
41 buckets
= (XAssoc
*)calloc((unsigned)size
, (unsigned)sizeof(XAssoc
));
42 if (buckets
== NULL
) {
43 /* calloc call failed! */
48 /* Insert table data into the XAssocTable structure. */
49 table
->buckets
= buckets
;
53 /* Initialize each bucket. */
54 buckets
->prev
= buckets
;
55 buckets
->next
= buckets
;
62 /* arch-tag: 5df3237d-ada0-4345-a3ab-282cafb397aa
63 (do not change this comment) */