提交 883a2e62 编写于 作者: C Christophe Tournery

Better solution to fix 64 bit compiler warnings

Use the size_t data type where appropriate instead of casting.
上级 65e09db1
......@@ -35,7 +35,7 @@
/* Doubles the allocated size associated to a pointer */
/* 'size' is the current allocated size. */
static void * mem_double(void * ptr, int size)
static void * mem_double(void * ptr, size_t size)
{
void * newptr ;
......@@ -87,11 +87,11 @@ static char * xstrdup(const char * s)
/*--------------------------------------------------------------------------*/
unsigned dictionary_hash(const char * key)
{
int len ;
size_t len ;
unsigned hash ;
int i ;
size_t i ;
len = (int)strlen(key);
len = strlen(key);
for (hash=0, i=0 ; i<len ; i++) {
hash += (unsigned)key[i] ;
hash += (hash<<10);
......@@ -249,9 +249,9 @@ int dictionary_set(dictionary * d, const char * key, const char * val)
if (d->n==d->size) {
/* Reached maximum size: reallocate dictionary */
d->val = (char **)mem_double(d->val, d->size * (int)sizeof(char*)) ;
d->key = (char **)mem_double(d->key, d->size * (int)sizeof(char*)) ;
d->hash = (unsigned int *)mem_double(d->hash, d->size * (int)sizeof(unsigned)) ;
d->val = (char **)mem_double(d->val, d->size * sizeof(char*)) ;
d->key = (char **)mem_double(d->key, d->size * sizeof(char*)) ;
d->hash = (unsigned int *)mem_double(d->hash, d->size * sizeof(unsigned)) ;
if ((d->val==NULL) || (d->key==NULL) || (d->hash==NULL)) {
/* Cannot grow dictionary */
return -1 ;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册