Mercurial > hg > xemacs-beta
comparison src/emacs-marshals.c @ 2515:de9952d2ed18
[xemacs-hg @ 2005-01-26 10:22:19 by ben]
Hash table cleanups, part 1 of 2
emacs-marshals.c, hash.c, hash.h, ui-gtk.c: Clean up and generalize creation of string hash tables.
ui-gtk.c, elhash.h, gccache-gtk.c, glyphs-gtk.c, lrecord.h, marker.c, objects-gtk.c, objects-msw.c, objects-tty.c, objects-x.c, objects.c, opaque.c, rangetab.c, specifier.c, specifier.h, xgccache.c: Use Hashcode rather than unsigned long.
author | ben |
---|---|
date | Wed, 26 Jan 2005 10:22:29 +0000 |
parents | 91d4c8c65a0f |
children |
comparison
equal
deleted
inserted
replaced
2514:b49d38bc659d | 2515:de9952d2ed18 |
---|---|
1464 *return_val = (*rfunc) (); | 1464 *return_val = (*rfunc) (); |
1465 } | 1465 } |
1466 | 1466 |
1467 | 1467 |
1468 #include "hash.h" | 1468 #include "hash.h" |
1469 static int | |
1470 our_string_eq (const void *st1, const void *st2) | |
1471 { | |
1472 if (!st1) | |
1473 return st2 ? 0 : 1; | |
1474 else if (!st2) | |
1475 return 0; | |
1476 else | |
1477 return !strcmp ( (const char *) st1, (const char *) st2); | |
1478 } | |
1479 | |
1480 static unsigned long | |
1481 our_string_hash (const void *xv) | |
1482 { | |
1483 unsigned int h = 0; | |
1484 unsigned const char *x = (unsigned const char *) xv; | |
1485 | |
1486 if (!x) return 0; | |
1487 | |
1488 while (*x) | |
1489 { | |
1490 unsigned int g; | |
1491 h = (h << 4) + *x++; | |
1492 if ((g = h & 0xf0000000) != 0) | |
1493 h = (h ^ (g >> 24)) ^ g; | |
1494 } | |
1495 | |
1496 return h; | |
1497 } | |
1498 | 1469 |
1499 static struct hash_table *marshaller_hashtable; | 1470 static struct hash_table *marshaller_hashtable; |
1500 | 1471 |
1501 static void initialize_marshaller_storage (void) | 1472 static void initialize_marshaller_storage (void) |
1502 { | 1473 { |
1503 if (!marshaller_hashtable) | 1474 if (!marshaller_hashtable) |
1504 { | 1475 { |
1505 marshaller_hashtable = make_general_hash_table (100, our_string_hash, our_string_eq); | 1476 marshaller_hashtable = make_string_hash_table (100); |
1506 puthash ("emacs_gtk_marshal_BOOL__OBJECT_INT", (void *) emacs_gtk_marshal_BOOL__OBJECT_INT, marshaller_hashtable); | 1477 puthash ("emacs_gtk_marshal_BOOL__OBJECT_INT", (void *) emacs_gtk_marshal_BOOL__OBJECT_INT, marshaller_hashtable); |
1507 puthash ("emacs_gtk_marshal_BOOL__OBJECT_OBJECT_OBJECT", (void *) emacs_gtk_marshal_BOOL__OBJECT_OBJECT_OBJECT, marshaller_hashtable); | 1478 puthash ("emacs_gtk_marshal_BOOL__OBJECT_OBJECT_OBJECT", (void *) emacs_gtk_marshal_BOOL__OBJECT_OBJECT_OBJECT, marshaller_hashtable); |
1508 puthash ("emacs_gtk_marshal_BOOL__OBJECT_OBJECT", (void *) emacs_gtk_marshal_BOOL__OBJECT_OBJECT, marshaller_hashtable); | 1479 puthash ("emacs_gtk_marshal_BOOL__OBJECT_OBJECT", (void *) emacs_gtk_marshal_BOOL__OBJECT_OBJECT, marshaller_hashtable); |
1509 puthash ("emacs_gtk_marshal_BOOL__OBJECT_POINTER", (void *) emacs_gtk_marshal_BOOL__OBJECT_POINTER, marshaller_hashtable); | 1480 puthash ("emacs_gtk_marshal_BOOL__OBJECT_POINTER", (void *) emacs_gtk_marshal_BOOL__OBJECT_POINTER, marshaller_hashtable); |
1510 puthash ("emacs_gtk_marshal_BOOL__OBJECT_STRING", (void *) emacs_gtk_marshal_BOOL__OBJECT_STRING, marshaller_hashtable); | 1481 puthash ("emacs_gtk_marshal_BOOL__OBJECT_STRING", (void *) emacs_gtk_marshal_BOOL__OBJECT_STRING, marshaller_hashtable); |