GithubHelp home page GithubHelp logo

hashmap's People

Contributors

barrust avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hashmap's Issues

Segfault when printing stats of empty hashmap

The following results in a segmentation fault:

HashMap h;
hashmap_init(&h);
hashmap_stats(&h);

The same is true after clearing the hashmap. Likely caused by malloc'ing memory based on the number of used nodes which is 0.

strncpy vs memcpy

Look into replacing strncpy with memcpy since all lengths are predefined and are known to not overlap.

HashFunction Type

Due to this being used with other, similar, libraries the HashFunction type should be made unique.

Can't read set map values between threads

I am running an OpenMP program with 2 threads. One thread sets some values and the other tries to read it but I don't get any set values back in the other thread

// thread 1 sets
int i = 0;
                for (i = 0; i < 10; i++)
                {
                    omp_set_lock(&writelock);
                    char key = i + '0';
                    printf("++setting key %d to val %d \n", key, i);
                    //#pragma omp critcal
                    hashmap_set_int(&h, &key, i);
                    omp_unset_lock(&writelock);
                }
               // thread 2 reading code
                sleep(5);
                int i = 0;
                for (i = 0; i < 10; i++)
                {
                    omp_set_lock(&writelock);
                    char key = i + '0';
                    int *hVal;
                    //#pragma omp critical
                    hVal = hashmap_get(&h, &key);
                    omp_unset_lock(&writelock);
                    if (hVal)
                    {
                        printf("hval is %d\n", *hVal);
                    }
                    else
                    {
                        printf("not found\n");
                    }
                }

HashMap h; is done at the top outside of main and hashmap_init(&h); is done in main

am I doing something wrong?

better unified header

If the unified header build is needed, then it should be more intelligent as to how it collects includes and the likes. Otherwise, it is probably not needed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.