projects
/
rrq
/
rrqmisc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
debugged: working
[rrq/rrqmisc.git]
/
tests
/
example-hashvector.c
diff --git
a/tests/example-hashvector.c
b/tests/example-hashvector.c
index 63c55822fd8e4dca846a6e2da54ac81d8466cdb1..516cd07393cc8e790e6b872a32453e767e18e7b2 100644
(file)
--- a/
tests/example-hashvector.c
+++ b/
tests/example-hashvector.c
@@
-8,15
+8,15
@@
typedef struct _ipslot {
unsigned int bits;
} ipslot;
unsigned int bits;
} ipslot;
-static unsigned long voidp_hashcode(void *key) {
+static unsigned long voidp_hashcode(
itemkeyfun *this,
void *key) {
return hashvector_hashcode( key, sizeof( ipslot ) );
}
return hashvector_hashcode( key, sizeof( ipslot ) );
}
-static void* voidp_itemkey(void *item) {
+static void* voidp_itemkey(
itemkeyfun *this,
void *item) {
return item;
}
return item;
}
-static int voidp_haskey(void *item,void *key) {
+static int voidp_haskey(
itemkeyfun *this,
void *item,void *key) {
return memcmp( item, key, sizeof( ipslot ) ) == 0;
}
return memcmp( item, key, sizeof( ipslot ) ) == 0;
}
@@
-33,13
+33,16
@@
static int shrink(vector *pv,unsigned long index,void *item,void *data) {
}
int main(int argc,char **argv) {
}
int main(int argc,char **argv) {
+ itemkeyfun voidpfun = {
+ .hashcode = voidp_hashcode,
+ .itemkey = voidp_itemkey,
+ .haskey = voidp_haskey
+ };
hashvector hv = {
.table = { 4, 0 },
.fill = 0,
.holes = 0,
hashvector hv = {
.table = { 4, 0 },
.fill = 0,
.holes = 0,
- .keyhashcode = voidp_hashcode,
- .itemkey = voidp_itemkey,
- .haskey = voidp_haskey
+ .type = &voidpfun
};
int i = 0;
for ( ; i < 259; i++ ) {
};
int i = 0;
for ( ; i < 259; i++ ) {
@@
-54,7
+57,7
@@
int main(int argc,char **argv) {
}
for ( i = 256; i < 260; i++ ) {
vector_index index = i;
}
for ( i = 256; i < 260; i++ ) {
vector_index index = i;
- void ** slot = vector_next_used( &hv.table, &index
, 0, 0
);
+ void ** slot = vector_next_used( &hv.table, &index );
if ( slot && *slot != HV_HOLE ) {
hashvector_delete( &hv, *slot );
}
if ( slot && *slot != HV_HOLE ) {
hashvector_delete( &hv, *slot );
}