dovecot: UID ranges can be large, don't allocate them from data ...
dovecot at dovecot.org
dovecot at dovecot.org
Fri Dec 7 16:17:02 EET 2007
details: http://hg.dovecot.org/dovecot/rev/5915aea5f070
changeset: 6945:5915aea5f070
user: Timo Sirainen <tss at iki.fi>
date: Fri Dec 07 16:16:58 2007 +0200
description:
UID ranges can be large, don't allocate them from data stack.
diffstat:
2 files changed, 43 insertions(+), 40 deletions(-)
src/plugins/fts-squat/squat-trie.c | 49 ++++++++++++++++-----------------
src/plugins/fts-squat/squat-uidlist.c | 34 ++++++++++++----------
diffs (113 lines):
diff -r 66b3e894041b -r 5915aea5f070 src/plugins/fts-squat/squat-trie.c
--- a/src/plugins/fts-squat/squat-trie.c Fri Dec 07 16:10:19 2007 +0200
+++ b/src/plugins/fts-squat/squat-trie.c Fri Dec 07 16:16:58 2007 +0200
@@ -1631,8 +1631,8 @@ squat_trie_lookup_real(struct squat_trie
ctx.type = type;
ctx.definite_uids = definite_uids;
ctx.maybe_uids = maybe_uids;
- t_array_init(&ctx.tmp_uids, 128);
- t_array_init(&ctx.tmp_uids2, 128);
+ i_array_init(&ctx.tmp_uids, 128);
+ i_array_init(&ctx.tmp_uids2, 128);
ctx.first = TRUE;
str_bytelen = strlen(str);
@@ -1667,31 +1667,32 @@ squat_trie_lookup_real(struct squat_trie
char_lengths,
i - start);
}
- squat_trie_add_unknown(trie, maybe_uids);
- return ret < 0 ? -1 : 0;
- }
-
- if (str_charlen <= trie->hdr.partial_len ||
- trie->hdr.full_len > trie->hdr.partial_len) {
- ret = squat_trie_lookup_data(trie, data, str_bytelen,
- &ctx.tmp_uids);
- if (ret > 0) {
- squat_trie_filter_type(type, &ctx.tmp_uids,
- definite_uids);
- }
} else {
- array_clear(definite_uids);
- }
-
- if (str_charlen <= trie->hdr.partial_len ||
- trie->hdr.partial_len == 0) {
- /* we have the result */
- array_clear(maybe_uids);
- } else {
- ret = squat_trie_lookup_partial(&ctx, data + start,
- char_lengths, i - start);
+ if (str_charlen <= trie->hdr.partial_len ||
+ trie->hdr.full_len > trie->hdr.partial_len) {
+ ret = squat_trie_lookup_data(trie, data, str_bytelen,
+ &ctx.tmp_uids);
+ if (ret > 0) {
+ squat_trie_filter_type(type, &ctx.tmp_uids,
+ definite_uids);
+ }
+ } else {
+ array_clear(definite_uids);
+ }
+
+ if (str_charlen <= trie->hdr.partial_len ||
+ trie->hdr.partial_len == 0) {
+ /* we have the result */
+ array_clear(maybe_uids);
+ } else {
+ ret = squat_trie_lookup_partial(&ctx, data + start,
+ char_lengths,
+ i - start);
+ }
}
squat_trie_add_unknown(trie, maybe_uids);
+ array_free(&ctx.tmp_uids);
+ array_free(&ctx.tmp_uids2);
return ret < 0 ? -1 : 0;
}
diff -r 66b3e894041b -r 5915aea5f070 src/plugins/fts-squat/squat-uidlist.c
--- a/src/plugins/fts-squat/squat-uidlist.c Fri Dec 07 16:10:19 2007 +0200
+++ b/src/plugins/fts-squat/squat-uidlist.c Fri Dec 07 16:16:58 2007 +0200
@@ -1364,22 +1364,24 @@ int squat_uidlist_get_seqrange(struct sq
struct seq_range range;
const uint32_t *tmp_uids;
unsigned int i, count;
-
- t_array_init(&tmp_uid_arr, 128);
- if (squat_uidlist_get(uidlist, uid_list_idx, &tmp_uid_arr) < 0)
- return -1;
-
- tmp_uids = array_get(&tmp_uid_arr, &count);
- for (i = 0; i < count; i++) {
- if ((tmp_uids[i] & UID_LIST_MASK_RANGE) == 0)
- range.seq1 = range.seq2 = tmp_uids[i];
- else {
- range.seq1 = tmp_uids[i] & ~UID_LIST_MASK_RANGE;
- range.seq2 = tmp_uids[++i];
- }
- array_append(seq_range_arr, &range, 1);
- }
- return 0;
+ int ret;
+
+ i_array_init(&tmp_uid_arr, 128);
+ ret = squat_uidlist_get(uidlist, uid_list_idx, &tmp_uid_arr);
+ if (ret == 0) {
+ tmp_uids = array_get(&tmp_uid_arr, &count);
+ for (i = 0; i < count; i++) {
+ if ((tmp_uids[i] & UID_LIST_MASK_RANGE) == 0)
+ range.seq1 = range.seq2 = tmp_uids[i];
+ else {
+ range.seq1 = tmp_uids[i] & ~UID_LIST_MASK_RANGE;
+ range.seq2 = tmp_uids[++i];
+ }
+ array_append(seq_range_arr, &range, 1);
+ }
+ }
+ array_free(&tmp_uid_arr);
+ return ret;
}
int squat_uidlist_filter(struct squat_uidlist *uidlist, uint32_t uid_list_idx,
More information about the dovecot-cvs
mailing list