int hashvector_find(hashvector *hv,void *key,void **x) {
void **p = hashvector_find_slot( hv, key );
if ( p && *p && *p != HV_HOLE ) {
- *x = *p;
+ if ( x ) {
+ *x = *p;
+ }
return 1;
}
return 0;
return 0;
}
+static int iter_item(unsigned long ix,void *item,void *data) {
+ if ( item && item != HV_HOLE ) {
+ hashvector_add( (hashvector *) data, item );
+ }
+ return 0;
+}
+
static void hashvector_resize(hashvector *hv,unsigned long new_size) {
hashvector tmp = *hv;
hv->table.size = new_size;
hv->table.entries = 0;
hv->fill = 0;
hv->holes = 0;
- pvector_resize( &tmp.table, 0, capture_item, hv );
+ if ( new_size < hv->table.size ) {
+ pvector_resize( &tmp.table, 0, capture_item, hv );
+ } else {
+ pvector_iterate( &tmp.table, iter_item, hv );
+ }
}
// Add the given element.