[dovecot-cvs] dovecot/src/lib-storage/index index-mail-headers.c,
1.44, 1.45 index-sync.c, 1.47, 1.48
cras at dovecot.org
cras at dovecot.org
Fri Apr 8 15:14:46 EEST 2005
Update of /var/lib/cvs/dovecot/src/lib-storage/index
In directory talvi:/tmp/cvs-serv22164/lib-storage/index
Modified Files:
index-mail-headers.c index-sync.c
Log Message:
Several size_t -> unsigned int changes. Try to keep "unsigned int" for
counters, size_t for actual memory range sizes.
Index: index-mail-headers.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail-headers.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- index-mail-headers.c 29 Mar 2005 16:48:45 -0000 1.44
+++ index-mail-headers.c 8 Apr 2005 12:14:43 -0000 1.45
@@ -18,7 +18,7 @@
struct mailbox_header_lookup_ctx ctx;
pool_t pool;
- size_t count;
+ unsigned int count;
unsigned int *idx;
const char **name;
};
@@ -600,46 +600,44 @@
struct index_header_lookup_ctx *ctx;
const char *const *name;
const char **sorted_headers;
- buffer_t *buf;
pool_t pool;
- size_t i, size;
+ unsigned int i, count;
- for (size = 0, name = headers; *name != NULL; name++)
- size++;
+ for (count = 0, name = headers; *name != NULL; name++)
+ count++;
t_push();
- if (size > 0) {
- /* headers need to be sorted for filter stream. */
- sorted_headers = t_new(const char *, size);
- memcpy(sorted_headers, headers, size * sizeof(*sorted_headers));
- qsort(sorted_headers, size, sizeof(*sorted_headers),
+ if (count > 0) {
+ /* @UNSAFE: headers need to be sorted for filter stream. */
+ sorted_headers = t_new(const char *, count);
+ memcpy(sorted_headers, headers,
+ count * sizeof(*sorted_headers));
+ qsort(sorted_headers, count, sizeof(*sorted_headers),
strcasecmp_p);
headers = sorted_headers;
}
- buf = buffer_create_dynamic(pool_datastack_create(), 128);
- for (i = 0; i < size; i++) {
+ /* @UNSAFE */
+ fields = t_new(struct mail_cache_field, count);
+ for (i = 0; i < count; i++) {
header_field.name = t_strconcat("hdr.", headers[i], NULL);
- buffer_append(buf, &header_field, sizeof(header_field));
+ fields[i] = header_field;
}
-
- fields = buffer_get_modifyable_data(buf, &size);
- size /= sizeof(*fields);
- mail_cache_register_fields(ibox->cache, fields, size);
+ mail_cache_register_fields(ibox->cache, fields, count);
pool = pool_alloconly_create("index_header_lookup_ctx", 256);
ctx = p_new(pool, struct index_header_lookup_ctx, 1);
ctx->ctx.box = box;
ctx->pool = pool;
- ctx->count = size;
+ ctx->count = count;
- if (size > 0) {
- ctx->idx = p_new(pool, unsigned int, size);
- ctx->name = p_new(pool, const char *, size);
+ if (count > 0) {
+ ctx->idx = p_new(pool, unsigned int, count);
+ ctx->name = p_new(pool, const char *, count);
/* @UNSAFE */
- for (i = 0; i < size; i++) {
+ for (i = 0; i < count; i++) {
ctx->idx[i] = fields[i].idx;
ctx->name[i] = p_strdup(pool, headers[i]);
}
Index: index-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-sync.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- index-sync.c 14 Mar 2005 21:18:02 -0000 1.47
+++ index-sync.c 8 Apr 2005 12:14:43 -0000 1.48
@@ -11,7 +11,7 @@
uint32_t messages_count;
const uint32_t *expunges;
- size_t expunges_count;
+ unsigned int expunges_count;
int failed;
};
More information about the dovecot-cvs
mailing list