Mercurial > hg > xemacs-beta
diff src/hash.c @ 185:3d6bfa290dbd r20-3b19
Import from CVS: tag r20-3b19
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:55:28 +0200 |
parents | 8eaf7971accc |
children | f955c73f5258 |
line wrap: on
line diff
--- a/src/hash.c Mon Aug 13 09:54:24 2007 +0200 +++ b/src/hash.c Mon Aug 13 09:55:28 2007 +0200 @@ -89,17 +89,14 @@ } static int -string_eq (CONST void *st1v, CONST void *st2v) +string_eq (CONST void *st1, CONST void *st2) { - CONST char *st1 = (CONST char *)st1v; - CONST char *st2 = (CONST char *)st2v; - if (!st1) - return (st2)?0:1; + return st2 ? 0 : 1; else if (!st2) return 0; else - return !strcmp (st1, st2); + return !strcmp ( (CONST char *) st1, (CONST char *) st2); } @@ -181,10 +178,9 @@ c_hashtable make_hashtable (unsigned int hsize) { - c_hashtable res = (c_hashtable) xmalloc (sizeof (struct _C_hashtable)); - memset (res, 0, sizeof (struct _C_hashtable)); + c_hashtable res = xnew_and_zero (struct _C_hashtable); res->size = prime_size ((13 * hsize) / 10); - res->harray = (hentry *) xmalloc (sizeof (hentry) * res->size); + res->harray = xnew_array (hentry, res->size); #ifdef emacs res->elisp_table = Qnil; #endif @@ -197,10 +193,9 @@ unsigned long (*hash_function) (CONST void *), int (*test_function) (CONST void *, CONST void *)) { - c_hashtable res = (c_hashtable) xmalloc (sizeof (struct _C_hashtable)); - memset (res, 0, sizeof (struct _C_hashtable)); + c_hashtable res = xnew_and_zero (struct _C_hashtable); res->size = prime_size ((13 * hsize) / 10); - res->harray = (hentry *) xmalloc (sizeof (hentry) * res->size); + res->harray = xnew_array (hentry, res->size); res->hash_function = hash_function; res->test_function = test_function; #ifdef emacs @@ -253,7 +248,7 @@ dest->elisp_table); else #endif - dest->harray = (hentry *) xmalloc (sizeof (hentry) * dest->size); + dest->harray = xnew_array (hentry, dest->size); } dest->fullness = src->fullness; dest->zero_entry = src->zero_entry;