barrust / hashmap Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Add a full suite of unittests using [minunit]https://github.com/barrust/c-utils/blob/master/src/minunit.h) from the c-utils library.
Bonus: add code coverage and continuous integration
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.
Look into replacing strncpy with memcpy since all lengths are predefined and are known to not overlap.
This should have an easier test suite to check that everything is working correctly
Due to this being used with other, similar, libraries the HashFunction type should be made unique.
Make it usable with C++
The repository's organization should be upated and releases should be provided.
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?
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.