Mercurial > dovecot > original-hg > dovecot-1.2
comparison src/plugins/trash/trash-plugin.c @ 5187:9dd18b285223 HEAD
Minor memory allocation optimizations.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 22 Feb 2007 17:03:46 +0200 |
parents | 24f4a959a24c |
children | 519ab252f1a3 |
comparison
equal
deleted
inserted
replaced
5186:a7627141ec7f | 5187:9dd18b285223 |
---|---|
11 | 11 |
12 #include <stdlib.h> | 12 #include <stdlib.h> |
13 #include <unistd.h> | 13 #include <unistd.h> |
14 #include <fcntl.h> | 14 #include <fcntl.h> |
15 | 15 |
16 #define INIT_TRASH_MAILBOX_COUNT 4 | |
16 #define MAX_RETRY_COUNT 3 | 17 #define MAX_RETRY_COUNT 3 |
17 | 18 |
18 struct trash_mailbox { | 19 struct trash_mailbox { |
19 const char *name; | 20 const char *name; |
20 int priority; /* lower number = higher priority */ | 21 int priority; /* lower number = higher priority */ |
234 i_error("open(%s) failed: %m", path); | 235 i_error("open(%s) failed: %m", path); |
235 return -1; | 236 return -1; |
236 } | 237 } |
237 | 238 |
238 p_clear(config_pool); | 239 p_clear(config_pool); |
239 p_array_init(&trash_boxes, config_pool, 8); | 240 p_array_init(&trash_boxes, config_pool, INIT_TRASH_MAILBOX_COUNT); |
240 | 241 |
241 input = i_stream_create_file(fd, default_pool, (size_t)-1, FALSE); | 242 input = i_stream_create_file(fd, default_pool, (size_t)-1, FALSE); |
242 while ((line = i_stream_read_next_line(input)) != NULL) { | 243 while ((line = i_stream_read_next_line(input)) != NULL) { |
243 /* <priority> <mailbox name> */ | 244 /* <priority> <mailbox name> */ |
244 name = strchr(line, ' '); | 245 name = strchr(line, ' '); |
269 if (quota_set == NULL) { | 270 if (quota_set == NULL) { |
270 i_error("trash plugin: quota plugin not initialized"); | 271 i_error("trash plugin: quota plugin not initialized"); |
271 return; | 272 return; |
272 } | 273 } |
273 | 274 |
274 config_pool = pool_alloconly_create("trash config", 1024); | 275 config_pool = pool_alloconly_create("trash config", |
276 sizeof(trash_boxes) + | |
277 BUFFER_APPROX_SIZE + | |
278 INIT_TRASH_MAILBOX_COUNT * | |
279 (sizeof(struct trash_mailbox) + 32)); | |
275 if (read_configuration(env) < 0) | 280 if (read_configuration(env) < 0) |
276 return; | 281 return; |
277 | 282 |
278 trash_next_quota_test_alloc = quota_set->test_alloc; | 283 trash_next_quota_test_alloc = quota_set->test_alloc; |
279 quota_set->test_alloc = trash_quota_test_alloc; | 284 quota_set->test_alloc = trash_quota_test_alloc; |