Comments (1)
keys are always copied internally (because growing the table would need to relocate them and anyway
you don't want a key do be modifiable once stored in the hashtable) ...
so you need to free you key (if alloc'd on the heap) when you don't need it anymore.
The value needs to be freed only if you are collecting it by passing a reference to the 'void **prev_data' argument (where to store the pointer to the value)
If you pass NULL the value will be freed using the callback provided at construction time.
Note that if you didn't provide any callback the value will be leaked .... you can also just pass 'free' as
callback.
In the documentation for the function (hashtable.h) I see :
- @note If prev_data is not NULL, the previous data will not be released using the free_value callback
-
so the caller will be responsible of releasing the previous data once done with it
change the comment if you think it's not clear enough and in case I'll be happy to merge a pull request.
from libhl.
Related Issues (20)
- Addition of a build system generator HOT 2
- Drop specifier "inline" for callback functions HOT 1
- Support for out-of-source builds HOT 2
- Complete build options for Pthread API HOT 4
- Selection of a directory for auxiliary build tools HOT 1
- Reuse of "libtool"? HOT 1
- Dynamic determination of the library build version HOT 2
- Include to a library HOT 2
- The lock-free circular queue currently requires one extra page in its internal ringbuffer to work properly HOT 2
- ATOMIC_CAS cann't work on ARM HOT 4
- Is there any document to introduce the APIs? HOT 2
- count not updated when removing items using the iterator HOT 2
- where can i find `ut.h', for compile the `test' directory's case? HOT 1
- Tons of key-value pairs. HOT 3
- Queue issue HOT 3
- How to build it in ubuntu?
- Queue Issues HOT 2
- Possible memory leak in binheap.c HOT 1
- Is rbuf lock-free for single-thread read and single-thread write ?
- ht_foreach_value return remove, will lose item HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libhl.