B
Bit Byter
I am hacking some legacy code and have put together a simple test to
test some hashing funcs I've written. I now want to do a simplistic
timing between the various structs.
Here's a snippet:
struct item_{
char key[16];
char data[32];
};
typedef struct {
struct item_ items[NUM_ITEMS];
}fakeHash ;
void fooBar(){
char buff[16];
/* 1. generate random index */
int rix =randix();
/* 2. generate key based off of random index */
sprintf(buff, "key%d",rix);
/* search for key using bsearch (keys already sorted)
bsearch((void*)&buff,(void*)fh.items.key,NUM_ITEMS,sizeof(struct
item_.key), (void*)strcmp )
*/
}
Any suggestions on using bsearch with this struct?. Note the commented
out code is only pseudo code. I KNOW it won't work
test some hashing funcs I've written. I now want to do a simplistic
timing between the various structs.
Here's a snippet:
struct item_{
char key[16];
char data[32];
};
typedef struct {
struct item_ items[NUM_ITEMS];
}fakeHash ;
void fooBar(){
char buff[16];
/* 1. generate random index */
int rix =randix();
/* 2. generate key based off of random index */
sprintf(buff, "key%d",rix);
/* search for key using bsearch (keys already sorted)
bsearch((void*)&buff,(void*)fh.items.key,NUM_ITEMS,sizeof(struct
item_.key), (void*)strcmp )
*/
}
Any suggestions on using bsearch with this struct?. Note the commented
out code is only pseudo code. I KNOW it won't work