|
From: | olegs |
Subject: | [Bug-mifluz] search/WordResults.cc |
Date: | Mon, 30 Jul 2001 14:37:09 -0700 |
There is an address alignment problem in search/WordResults.cc/wordResults_cmp(...):
b->data may be odd-aligned. See quick and dirty fix below.
Platform: Solaris, compiler: Sun CC (Workshop 6)
static int wordResults_cmp(const DBT* a, const DBT* b)
{
int length = (int)a->app_private;
// olegs - invalid alignment with b->data="" (data is byte array, wordkey is uint)
if(reinterpret_cast<int>(b->data)%sizeof(WordKeyNum)!=0) {
WordKeyNum* a_values = (WordKeyNum*)a->data;
WordKeyNum* b_values = new WordKeyNum(length);
for(int i=0; i<length; i++) {b_values[i]=(WordKeyNum)((uint8_t*)b->data)[i];}
for(int i = 0; i < length; i++) {
if(a_values[i] != b_values[i]) {
delete b_values;
return a_values[i] > b_values[i] ? 1 : -1;
}
}
delete b_values;
return 0;
}
// end olegs
WordKeyNum* a_values = (WordKeyNum*)a->data;
WordKeyNum* b_values = (WordKeyNum*)b->data;
for(int i = 0; i < length; i++) {
if(a_values[i] != b_values[i]) {
return a_values[i] > b_values[i] ? 1 : -1;
}
}
return 0;
}
Oleg Sinitsin
Staff Engineer
Commerce Development
>
e-centives, Inc.
555 Twin Dolphin Drive, Suite 200
Redwood Shores, CA 94065
650.620.2419 direct
650.620.2499 fax
[Prev in Thread] | Current Thread | [Next in Thread] |