Fixed list/hash autofree strategy #103

Merged
merged 2 commits into from Dec 8, 2012

Conversation

Projects
None yet
2 participants
@hintjens
Member

hintjens commented Dec 8, 2012

Was breaking systematically since it depended on caller to strdup passed values; omitting this created a hard-to-find error. Now the insert/update methods all duplicate the passed value/item for dynamic containers. If callers also duplicate the item the result is a dangling allocation, which is easy to find.

hintjens added some commits Nov 28, 2012

Improved containers handling of autofree items
* zhash duplicates item value if container has autofree set
* zlist duplicates item if container has autofree set

This is to get around anti-pattern where caller is responsible for strdup,
and forgetting it causes a double-free. It's easier to detect a dangling
allocation than a double-free.

felipecruz pushed a commit that referenced this pull request Dec 8, 2012

Felipe cruz
Merge pull request #103 from hintjens/master
Fixed list/hash autofree strategy

@felipecruz felipecruz merged commit 799a880 into zeromq:master Dec 8, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment