-const char miscutil_rcs[] = "$Id: miscutil.c,v 1.67 2011/05/22 10:30:55 fabiankeil Exp $";
+const char miscutil_rcs[] = "$Id: miscutil.c,v 1.70 2012/03/04 11:48:34 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/miscutil.c,v $
* Function : zalloc
*
* Description : Malloc some memory and set it to '\0'.
- * The way calloc() ought to be -acjc
*
* Parameters :
* 1 : size = Size of memory chunk to return.
* Function : hash_string
*
* Description : Take a string and compute a (hopefuly) unique numeric
- * integer value. This has several uses, but being able
- * to "switch" a string the one of my favorites.
+ * integer value. This is useful to "switch" a string.
*
* Parameters :
* 1 : s : string to be hashed.
*
- * Returns : an unsigned long variable with the hashed value.
+ * Returns : The string's hash
*
*********************************************************************/
unsigned int hash_string( const char* s )
{
char *duplicate;
- if (NULL == (duplicate = (char *)malloc(len)))
+ duplicate = (char *)malloc(len);
+ if (NULL != duplicate)
{
- return NULL;
- }
- else
- {
- memcpy(duplicate, string, len);
+ memcpy(duplicate, string, len);
}
return duplicate;