fix some allocation/free bugs when we put non objects into table...
authorBrian Demsky <bdemsky@uci.edu>
Fri, 20 Jul 2012 21:48:01 +0000 (14:48 -0700)
committerBrian Norris <banorris@uci.edu>
Thu, 2 Aug 2012 17:12:50 +0000 (10:12 -0700)
hashtable.h

index c877d9f1753d9dc0bd3e0a7d2dc4181f7ac636c4..4eae7571d24af74369b0f5ba55ebce40cd297a48 100644 (file)
@@ -36,7 +36,7 @@ template<typename _Key, typename _Val, typename _KeyInt, int _Shift=0, void * (*
                        struct hashlistnode<_Key,_Val> * bin = table[i];
                        while(bin!=NULL) {
                                struct hashlistnode<_Key,_Val> * next=bin->next;
-                               _free(bin);
+                               delete bin;
                                bin=next;
                        }
                }
@@ -65,7 +65,7 @@ template<typename _Key, typename _Val, typename _KeyInt, int _Shift=0, void * (*
                        struct hashlistnode<_Key,_Val> * bin = table[i];
                        while(bin!=NULL) {
                                struct hashlistnode<_Key,_Val> * next=bin->next;
-                               _free(bin);
+                               delete bin;
                                bin=next;
                        }
                }
@@ -93,7 +93,7 @@ template<typename _Key, typename _Val, typename _KeyInt, int _Shift=0, void * (*
                        search=search->next;
                }
 
-               struct hashlistnode<_Key,_Val> *newptr=(struct hashlistnode<_Key,_Val> *)_malloc(sizeof(struct hashlistnode<_Key,_Val>));
+               struct hashlistnode<_Key,_Val> *newptr=(struct hashlistnode<_Key,_Val> *)new struct hashlistnode<_Key,_Val>;
                newptr->key=key;
                newptr->val=val;
                newptr->next=ptr;