From 354f1142c4cc8c59b6f1170b95caec40bfe4d8c0 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 14 Nov 2012 10:22:13 +0100 Subject: [PATCH 1/1] Replace key_compare_it with key_compare This is because key_compare_it throws exception on some CPUs with alignment constraints. --- include/it_key.h | 1 - index/kcontrol.c | 2 +- index/trunc.c | 8 ++++---- util/it_key.c | 19 ------------------- 4 files changed, 5 insertions(+), 25 deletions(-) diff --git a/include/it_key.h b/include/it_key.h index c52d47e..40071fc 100644 --- a/include/it_key.h +++ b/include/it_key.h @@ -43,7 +43,6 @@ int key_compare(const void *p1, const void *p2); void key_init(struct it_key *k); zint key_get_seq(const void *p); zint key_get_segment(const void *p); -int key_compare_it(const void *p1, const void *p2); int key_qsort_compare(const void *p1, const void *p2); char *key_print_it(const void *p, char *buf); void key_logdump(int mask, const void *p); diff --git a/index/kcontrol.c b/index/kcontrol.c index ce413f5..0317d03 100644 --- a/index/kcontrol.c +++ b/index/kcontrol.c @@ -61,7 +61,7 @@ struct rset_key_control *zebra_key_control_create(ZebraHandle zh) kc->context = cp; kc->key_size = sizeof(struct it_key); - kc->cmp = key_compare_it; + kc->cmp = key_compare; kc->key_logdump_txt = key_logdump_txt; kc->getseq = key_get_seq; diff --git a/index/trunc.c b/index/trunc.c index 1127c1f..eb81fbb 100644 --- a/index/trunc.c +++ b/index/trunc.c @@ -169,7 +169,7 @@ static RSET rset_trunc_r(ZebraHandle zi, const char *term, int length, kctrl, scope, 0); rscur++; } - ti = heap_init (rscur, sizeof(struct it_key), key_compare_it); + ti = heap_init (rscur, sizeof(struct it_key), key_compare); for (i = rscur; --i >= 0; ) { rsfd[i] = rset_open(rset[i], RSETF_READ); @@ -219,7 +219,7 @@ static RSET rset_trunc_r(ZebraHandle zi, const char *term, int length, ispt = (ISAMC_PP *) xmalloc(sizeof(*ispt) * (to-from)); ti = heap_init(to-from, sizeof(struct it_key), - key_compare_it); + key_compare); for (i = to-from; --i >= 0; ) { ispt[i] = isamc_pp_open(zi->reg->isamc, isam_p[from+i]); @@ -274,7 +274,7 @@ static RSET rset_trunc_r(ZebraHandle zi, const char *term, int length, ispt = (ISAMS_PP *) xmalloc(sizeof(*ispt) * (to-from)); ti = heap_init(to-from, sizeof(struct it_key), - key_compare_it); + key_compare); for (i = to-from; --i >= 0; ) { ispt[i] = isams_pp_open(zi->reg->isams, isam_p[from+i]); @@ -317,7 +317,7 @@ static RSET rset_trunc_r(ZebraHandle zi, const char *term, int length, ispt = (ISAMB_PP *) xmalloc(sizeof(*ispt) * (to-from)); ti = heap_init(to-from, sizeof(struct it_key), - key_compare_it); + key_compare); for (i = to-from; --i >= 0; ) { if (isam_p[from+i]) { diff --git a/util/it_key.c b/util/it_key.c index 5ec244b..205ce6f 100644 --- a/util/it_key.c +++ b/util/it_key.c @@ -64,25 +64,6 @@ void key_logdump(int logmask, const void *p) key_logdump_txt(logmask, p, ""); } -int key_compare_it (const void *p1, const void *p2) -{ - int i, l = ((struct it_key *) p1)->len; - if (((struct it_key *) p2)->len > l) - l = ((struct it_key *) p2)->len; - assert (l <= IT_KEY_LEVEL_MAX && l > 0); - for (i = 0; i < l; i++) - { - if (((struct it_key *) p1)->mem[i] != ((struct it_key *) p2)->mem[i]) - { - if (((struct it_key *) p1)->mem[i] > ((struct it_key *) p2)->mem[i]) - return l-i; - else - return i-l; - } - } - return 0; -} - char *key_print_it (const void *p, char *buf) { strcpy(buf, ""); -- 1.7.10.4