projects
/
rrq
/
rrqmisc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
debugging
[rrq/rrqmisc.git]
/
pvector
/
hashvector.c
diff --git
a/pvector/hashvector.c
b/pvector/hashvector.c
index 5efbd8af801eda3927d8265c2d4553cb4678f5ef..5164ffe2e209291388fafcbf812ae57940ed7233 100644
(file)
--- a/
pvector/hashvector.c
+++ b/
pvector/hashvector.c
@@
-39,7
+39,9
@@
static void **hashvector_find_slot(hashvector *hv,void *key) {
int hashvector_find(hashvector *hv,void *key,void **x) {
void **p = hashvector_find_slot( hv, key );
if ( p && *p && *p != HV_HOLE ) {
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 1;
}
return 0;
@@
-52,13
+54,24
@@
static int capture_item(pvector *pv,unsigned long ix,void *item,void *data) {
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;
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.
}
// Add the given element.