Only save .newsrc file if the native method is NNTP
[emacs.git] / oldXMenu / XCrAssoc.c
blob7150cbc53d63ee25c0be42e3210a9e0e68cd80f6
1 /* Copyright Massachusetts Institute of Technology 1985 */
2 #include "copyright.h"
5 #include <config.h>
6 #include <stdlib.h>
7 #include <X11/Xlib.h>
8 #include <errno.h>
9 #include "X10.h"
11 #ifndef NULL
12 #define NULL 0
13 #endif
16 * XCreateAssocTable - Create an XAssocTable. The size argument should be
17 * a power of two for efficiency reasons. Some size suggestions: use 32
18 * buckets per 100 objects; a reasonable maximum number of object per
19 * buckets is 8. If there is an error creating the XAssocTable, a NULL
20 * pointer is returned.
22 XAssocTable *XCreateAssocTable(register int size)
23 /* Desired size of the table. */
25 register XAssocTable *table; /* XAssocTable to be initialized. */
26 register XAssoc *buckets; /* Pointer to the first bucket in */
27 /* the bucket array. */
29 /* Malloc the XAssocTable. */
30 if ((table = (XAssocTable *)malloc(sizeof(XAssocTable))) == NULL) {
31 /* malloc call failed! */
32 errno = ENOMEM;
33 return(NULL);
36 /* calloc the buckets (actually just their headers). */
37 buckets = (XAssoc *)calloc((unsigned)size, (unsigned)sizeof(XAssoc));
38 if (buckets == NULL) {
39 /* calloc call failed! */
40 errno = ENOMEM;
41 return(NULL);
44 /* Insert table data into the XAssocTable structure. */
45 table->buckets = buckets;
46 table->size = size;
48 while (--size >= 0) {
49 /* Initialize each bucket. */
50 buckets->prev = buckets;
51 buckets->next = buckets;
52 buckets++;
55 return(table);