File tree Expand file tree Collapse file tree 2 files changed +2
-13
lines changed Expand file tree Collapse file tree 2 files changed +2
-13
lines changed Original file line number Diff line number Diff line change @@ -131,19 +131,9 @@ double itable_load(struct itable *h)
131131static int insert_to_buckets_aux (struct entry * * buckets , int bucket_count , struct entry * new_entry )
132132{
133133 unsigned index ;
134- struct entry * e ;
135-
136134 index = new_entry -> key % bucket_count ;
137- e = buckets [index ];
138-
139- while (e ) {
140- /* check that this key does not already exist in the table */
141- if (new_entry -> key == e -> key ) {
142- return 0 ;
143- }
144- e = e -> next ;
145- }
146135
136+ // Possible memory leak! Silently replacing value if it existed.
147137 new_entry -> next = buckets [index ];
148138 buckets [index ] = new_entry ;
149139 return 1 ;
Original file line number Diff line number Diff line change @@ -103,8 +103,7 @@ double itable_load(struct itable *h);
103103
104104
105105/** Insert a key and value.
106- This call will fail if the table already contains the same key.
107- You must call @ref itable_remove to remove it.
106+ This call will replace the value if it already contains the same key.
108107Also note that you cannot insert a null value into the table.
109108@param h A pointer to an integer table.
110109@param key An integer key
You can’t perform that action at this time.
0 commit comments