1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Array of Linked Lists: Status Access Violation!!

Discussion in 'C' started by Zyreal687, Aug 31, 2010.

  1. Zyreal687

    Zyreal687 New Member

    Aug 31, 2010
    Likes Received:
    Trophy Points:
    I'm building a 'simulated' web browsing experience that simply intakes character strings, pretends their URLs, and does what a web browser would do. It creates a cache and moves strings that have already been encountered to the front of the list etc. Note it begins with an array of structures that contain pointers to linked lists.

    The problem i'm having is when i call any of my functions all i get is:
    0 [main] WebBrowse 5456 exception::handle: Exception: STATUS_ACCESS_VIOLATION
    307 [main] WebBrowse 5456 open_stackdumpfile: Dumping stack trace to WebBrowse.exe.stackdump 
    here is my code:
    #define HASHSIZE 101
    #define MAXLIST 5
    struct hashlist{
            int listsize;//number of items in linked list
            struct linklist *head;//pointer to head of linked list
            struct linklist *tail;//pointer to tail of linked list
    struct linklist{
            struct linklist *next; // pointer to next entry in chain
            char *str; // page name
            int count; // count for occurrence
    static struct hashlist *hashtab[HASHSIZE]; // pointer table
    /*hash: form hash value for string s */
    unsigned int hash(char *s){
            unsigned hashval;
            for(hashval = 0; *s != '\0'; s++)
                    hashval = *s + 31 * hashval;
            return hashval % HASHSIZE;
    /*builds the structure with input string*/
    struct linklist *buildNode(char *s){
            struct linklist *temp = NULL;
            temp = malloc(sizeof(struct linklist));
            temp->str = s;
            temp->count = 0;
            temp->next = NULL;
            return temp;
    /*searches linked list to see if string already exists*/
    struct linklist *search(char *s){
            struct linklist *np;
            for(np = hashtab[hash(s)]->head; np != NULL; np = np->next){
                    if(strcmp(s, np->str) == 0)
                            return np; //found it
            return NULL; //didn't find it
    /*inserts structure into list*/
    struct linklist *insert(char *url){
            struct linklist *test = NULL;
            struct linklist *ins = NULL;
            if((test = search(url)) == NULL) //doesnt yet exist
                    ins = buildNode(url);
            hashtab[hash(url)]->head = &ins;
            return ins;
    when i use:
    int main(){
            setvbuf(stdout, NULL, _IONBF, 0);
            char s[] = "test";
            return 0;
    the above error results. I understand the conceptual aspect of the linked list and how the hash function works, but i can't get my code to stop giving me this error.

    Am i using pointers incorrectly, or using values when pointer parameters are called? What does Status_Access_Violation signify? Any help would be greatly appreciated. If i was unclear with any of these let me know. Please help!

Share This Page