Expand chaining hashtable. Errors on code.

Posted by FILIaS on Stack Overflow See other posts from Stack Overflow or by FILIaS
Published on 2011-01-15T23:51:13Z Indexed on 2011/01/15 23:53 UTC
Read the original article Hit count: 255

Filed under:
|
|
|

Expanding a hashtable with linked lists there are some errors and warnings. I wanna make sure that the following code is right (expand method) and find out what happens that raise these warnings/errors

    typedef struct 
    {
        int length;        
        struct  List *head;    
        struct  List *tail;
    } HashTable;

    //resolving collisions using linked lists - chaining
    typedef struct 
    {
        char *number;
        char *name;
        int time;
        struct List *next;
    }List;



    //on the insert method i wanna check hashtable's size, 
    //if it seems appropriate there is the following code:
    //Note: hashtable variable is: Hashtable *
    ......
    hashtable = expand(hashtable,number,name,time);    /**WARNING**:assignment makes
 pointer from integer without a cast*/



     HashTable* expand( HashTable* h ,char number[10],char* name,int time) /**error**:
 conflicting types for ‘expand’ previous implicit declaration of ‘expand’ was here*/

    {   
        HashTable* new;
        int n;
        clientsList *node,*next;
        PrimesIndex++;
        int new_size= primes[PrimesIndex];  /* double the size,odd length */

        if (!(new=malloc((sizeof( List*))*new_size))) return NULL;

        for(n=0; n< h->length; ++n) {
            for(node=h[n].head; node; node=next) {
                add (&new, node->number, node->name,node->time);
                next=node->next;////
                free(node);
            }
        }
        free(h);
        return new;
    }

© Stack Overflow or respective owner

Related posts about c

    Related posts about hashtable