(cua-paste): Handle x-clipboard-yank.
[bpt/emacs.git] / oldXMenu / XCrAssoc.c
CommitLineData
e745ede7 1/* Copyright Massachusetts Institute of Technology 1985 */
61e1e4e8 2/* Copyright (C) 2001, 2002, 2003, 2004, 2005,
4e6835db 3 2006, 2007 Free Software Foundation, Inc. */
e745ede7
DL
4
5/*
6Permission to use, copy, modify, distribute, and sell this software and its
7documentation for any purpose is hereby granted without fee, provided that
8the above copyright notice appear in all copies and that both that
9copyright notice and this permission notice appear in supporting
10documentation, and that the name of M.I.T. not be used in advertising or
11publicity pertaining to distribution of the software without specific,
12written prior permission. M.I.T. makes no representations about the
13suitability of this software for any purpose. It is provided "as is"
14without express or implied warranty.
15*/
16
17#include <config.h>
18#include <X11/Xlib.h>
19#include <errno.h>
20#include "X10.h"
21
22#ifndef NULL
23#define NULL 0
24#endif
25
26extern int errno;
27
28/*
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.
34 */
35XAssocTable *XCreateAssocTable(size)
36 register int size; /* Desired size of the table. */
37{
38 register XAssocTable *table; /* XAssocTable to be initialized. */
39 register XAssoc *buckets; /* Pointer to the first bucket in */
40 /* the bucket array. */
177c0ea7 41
e745ede7
DL
42 /* Malloc the XAssocTable. */
43 if ((table = (XAssocTable *)malloc(sizeof(XAssocTable))) == NULL) {
44 /* malloc call failed! */
45 errno = ENOMEM;
46 return(NULL);
47 }
177c0ea7 48
e745ede7
DL
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! */
53 errno = ENOMEM;
54 return(NULL);
55 }
56
57 /* Insert table data into the XAssocTable structure. */
58 table->buckets = buckets;
59 table->size = size;
60
61 while (--size >= 0) {
62 /* Initialize each bucket. */
63 buckets->prev = buckets;
64 buckets->next = buckets;
65 buckets++;
66 }
67
68 return(table);
69}
ab5796a9
MB
70
71/* arch-tag: 5df3237d-ada0-4345-a3ab-282cafb397aa
72 (do not change this comment) */