12 struct node
*nodes
[MODULUS
];
15 static unsigned hash(const char *s
) {
24 struct dict
*dict_new(void) {
25 return xmalloc(sizeof (struct dict
));
28 int dict_add(struct dict
*d
, const char *key
, void *data
) {
29 unsigned h
= hash(key
);
32 for(n
= d
->nodes
[h
]; n
; n
= n
->next
)
33 if(!strcmp(key
, n
->key
))
35 n
= xmalloc(sizeof *n
);
36 n
->next
= d
->nodes
[h
];
37 n
->key
= xstrdup(key
);
43 void *dict_get(struct dict
*d
, const char *key
) {
44 unsigned h
= hash(key
);
47 for(n
= d
->nodes
[h
]; n
; n
= n
->next
)
48 if(!strcmp(key
, n
->key
))