[dovecot-cvs] dovecot/src/lib-index mail-cache-compress.c, 1.22, 1.23 mail-cache-fields.c, 1.7, 1.8 mail-cache-lookup.c, 1.23, 1.24 mail-cache-transaction.c, 1.28, 1.29 mail-cache.c, 1.47, 1.48 mail-index-sync.c, 1.33, 1.34 mail-index-transaction.c, 1.30, 1.31 mail-index-view-sync.c, 1.21, 1.22 mail-index-view.c, 1.21, 1.22 mail-index.c, 1.150, 1.151 mail-transaction-log.c, 1.61, 1.62

cras at dovecot.org cras at dovecot.org
Fri Oct 8 20:51:51 EEST 2004


Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv10130/lib-index

Modified Files:
	mail-cache-compress.c mail-cache-fields.c mail-cache-lookup.c 
	mail-cache-transaction.c mail-cache.c mail-index-sync.c 
	mail-index-transaction.c mail-index-view-sync.c 
	mail-index-view.c mail-index.c mail-transaction-log.c 
Log Message:
Buffer API change: we no longer support limited sized buffers where
writes past limit wouldn't kill the process. They weren't used hardly
anywhere, they could have hidden bugs and the code for handling them was too
complex.

This also changed base64 and hex-binary APIs.



Index: mail-cache-compress.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-compress.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- mail-cache-compress.c	7 Oct 2004 20:36:48 -0000	1.22
+++ mail-cache-compress.c	8 Oct 2004 17:51:48 -0000	1.23
@@ -135,8 +135,8 @@
 	o_stream_send(output, &hdr, sizeof(hdr));
 
 	memset(&ctx, 0, sizeof(ctx));
-	ctx.buffer = buffer_create_dynamic(default_pool, 4096, (size_t)-1);
-	ctx.field_seen = buffer_create_dynamic(default_pool, 64, (size_t)-1);
+	ctx.buffer = buffer_create_dynamic(default_pool, 4096);
+	ctx.field_seen = buffer_create_dynamic(default_pool, 64);
 	ctx.field_seen_value = 0;
 
 	mail_index_reset_cache(t, hdr.file_seq);
@@ -181,8 +181,7 @@
                         cache->field_file_map[i] = (uint32_t)-1;
 
 		t_push();
-		buffer = buffer_create_dynamic(pool_datastack_create(),
-					       256, (size_t)-1);
+		buffer = buffer_create_dynamic(pool_datastack_create(), 256);
 		mail_cache_header_fields_get(cache, buffer);
 		o_stream_send(output, buffer_get_data(buffer, NULL),
 			      buffer_get_used_size(buffer));

Index: mail-cache-fields.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-fields.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- mail-cache-fields.c	11 Sep 2004 17:25:39 -0000	1.7
+++ mail-cache-fields.c	8 Oct 2004 17:51:48 -0000	1.8
@@ -281,8 +281,7 @@
 	}
 
 	t_push();
-	buffer = buffer_create_dynamic(pool_datastack_create(),
-				       256, (size_t)-1);
+	buffer = buffer_create_dynamic(pool_datastack_create(), 256);
 
 	copy_to_buf(cache, buffer,
 		    offsetof(struct mail_cache_field_private, last_used),

Index: mail-cache-lookup.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-lookup.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- mail-cache-lookup.c	16 Sep 2004 14:33:16 -0000	1.23
+++ mail-cache-lookup.c	8 Oct 2004 17:51:48 -0000	1.24
@@ -430,7 +430,7 @@
 	ctx.fields_count = fields_count;
 
 	ctx.max_field = 0;
-	buf = buffer_create_dynamic(pool_datastack_create(), 32, (size_t)-1);
+	buf = buffer_create_dynamic(pool_datastack_create(), 32);
 	for (i = 0; i < fields_count; i++) {
 		i_assert(fields[i] < cache->fields_count);
 		if (cache->field_file_map[fields[i]] == (unsigned int)-1) {
@@ -447,8 +447,7 @@
 	}
 	ctx.fields_found = buffer_get_modifyable_data(buf, NULL);
 
-	ctx.data = buffer_create_dynamic(pool_datastack_create(),
-					 256, (size_t)-1);
+	ctx.data = buffer_create_dynamic(pool_datastack_create(), 256);
 
 	/* we need to return them in sorted order. create array:
 	   { line number -> cache file offset } */

Index: mail-cache-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-transaction.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- mail-cache-transaction.c	11 Sep 2004 17:25:39 -0000	1.28
+++ mail-cache-transaction.c	8 Oct 2004 17:51:48 -0000	1.29
@@ -45,8 +45,7 @@
 	ctx->cache = view->cache;
 	ctx->view = view;
 	ctx->trans = t;
-	ctx->reservations =
-		buffer_create_dynamic(system_pool, 256, (size_t)-1);
+	ctx->reservations = buffer_create_dynamic(system_pool, 256);
 
 	if (!MAIL_CACHE_IS_UNUSABLE(ctx->cache))
 		ctx->cache_file_seq = ctx->cache->hdr->file_seq;
@@ -484,10 +483,8 @@
 			      sizeof(ctx->prev_seq));
 		ctx->prev_pos = size;
 	} else if (ctx->cache_data == NULL) {
-		ctx->cache_data =
-			buffer_create_dynamic(system_pool, 32768, (size_t)-1);
-		ctx->cache_data_seq =
-			buffer_create_dynamic(system_pool, 256, (size_t)-1);
+		ctx->cache_data = buffer_create_dynamic(system_pool, 32768);
+		ctx->cache_data_seq = buffer_create_dynamic(system_pool, 256);
 	}
 
 	memset(&new_rec, 0, sizeof(new_rec));
@@ -589,8 +586,7 @@
 	}
 
 	t_push();
-	buffer = buffer_create_dynamic(pool_datastack_create(),
-				       256, (size_t)-1);
+	buffer = buffer_create_dynamic(pool_datastack_create(), 256);
 	mail_cache_header_fields_get(cache, buffer);
 	data = buffer_get_data(buffer, &size);
 

Index: mail-cache.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- mail-cache.c	16 Sep 2004 14:33:16 -0000	1.47
+++ mail-cache.c	8 Oct 2004 17:51:48 -0000	1.48
@@ -333,12 +333,10 @@
 	view = i_new(struct mail_cache_view, 1);
 	view->cache = cache;
 	view->view = iview;
-	view->offsets_buf =
-		buffer_create_dynamic(default_pool, 128, (size_t)-1);
+	view->offsets_buf = buffer_create_dynamic(default_pool, 128);
 	view->cached_exists_buf =
 		buffer_create_dynamic(default_pool,
-				      cache->file_fields_count + 10,
-				      (size_t)-1);
+				      cache->file_fields_count + 10);
 	return view;
 }
 

Index: mail-index-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-sync.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- mail-index-sync.c	8 Oct 2004 17:06:18 -0000	1.33
+++ mail-index-sync.c	8 Oct 2004 17:51:48 -0000	1.34
@@ -309,10 +309,8 @@
 
 	/* we need to have all the transactions sorted to optimize
 	   caller's mailbox access patterns */
-	ctx->expunges_buf = buffer_create_dynamic(default_pool,
-						  1024, (size_t)-1);
-	ctx->updates_buf = buffer_create_dynamic(default_pool,
-						 1024, (size_t)-1);
+	ctx->expunges_buf = buffer_create_dynamic(default_pool, 1024);
+	ctx->updates_buf = buffer_create_dynamic(default_pool, 1024);
 	if (mail_index_sync_read_and_sort(ctx, sync_recent) < 0) {
                 mail_index_sync_rollback(ctx);
 		return -1;

Index: mail-index-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-transaction.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- mail-index-transaction.c	3 Oct 2004 16:32:59 -0000	1.30
+++ mail-index-transaction.c	8 Oct 2004 17:51:48 -0000	1.31
@@ -199,10 +199,8 @@
 
 	t->log_updates = TRUE;
 
-	if (t->appends == NULL) {
-		t->appends = buffer_create_dynamic(default_pool,
-						   4096, (size_t)-1);
-	}
+	if (t->appends == NULL)
+		t->appends = buffer_create_dynamic(default_pool, 4096);
 
 	/* sequence number is visible only inside given view,
 	   so let it generate it */
@@ -256,8 +254,7 @@
 	/* expunges is a sorted array of {seq1, seq2, ..}, .. */
 
 	if (t->expunges == NULL) {
-		t->expunges = buffer_create_dynamic(default_pool,
-						    1024, (size_t)-1);
+		t->expunges = buffer_create_dynamic(default_pool, 1024);
 		buffer_append(t->expunges, &exp, sizeof(exp));
 		return;
 	}
@@ -447,10 +444,8 @@
 
         mail_index_transaction_get_last(t, &update);
 
-	if (t->updates == NULL) {
-		t->updates = buffer_create_dynamic(default_pool,
-						   4096, (size_t)-1);
-	}
+	if (t->updates == NULL)
+		t->updates = buffer_create_dynamic(default_pool, 4096);
 
 	data = buffer_get_modifyable_data(t->updates, &size);
 	size /= sizeof(*data);
@@ -543,7 +538,7 @@
 	size_t pos;
 
 	if (*buffer == NULL) {
-		*buffer = buffer_create_dynamic(default_pool, 1024, (size_t)-1);
+		*buffer = buffer_create_dynamic(default_pool, 1024);
 		buffer_append(*buffer, &seq, sizeof(seq));
 		buffer_append(*buffer, record, record_size);
 		return FALSE;
@@ -694,10 +689,8 @@
 		 (ext->record_size == record_size &&
 		  ext->record_align == record_align));
 
-	if (t->ext_resizes == NULL) {
-		t->ext_resizes =
-			buffer_create_dynamic(default_pool, 128, (size_t)-1);
-	}
+	if (t->ext_resizes == NULL)
+		t->ext_resizes = buffer_create_dynamic(default_pool, 128);
 
 	intro.hdr_size = hdr_size;
 	intro.record_size = record_size;
@@ -745,10 +738,8 @@
 		record_size = ext[ext_id].record_size;
 	}
 
-	if (t->ext_rec_updates == NULL) {
-		t->ext_rec_updates =
-			buffer_create_dynamic(default_pool, 128, (size_t)-1);
-	}
+	if (t->ext_rec_updates == NULL)
+		t->ext_rec_updates = buffer_create_dynamic(default_pool, 128);
 	buf = buffer_get_space_unsafe(t->ext_rec_updates,
 				      ext_id * sizeof(buffer_t *),
 				      sizeof(buffer_t *));

Index: mail-index-view-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-view-sync.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- mail-index-view-sync.c	3 Oct 2004 16:32:59 -0000	1.21
+++ mail-index-view-sync.c	8 Oct 2004 17:51:48 -0000	1.22
@@ -30,7 +30,7 @@
 	size_t size;
 	int ret;
 
-	*expunges_r = buffer_create_dynamic(default_pool, 512, (size_t)-1);
+	*expunges_r = buffer_create_dynamic(default_pool, 512);
 
 	/* with mask 0 we don't get anything, we'll just read the expunges
 	   while seeking to end */
@@ -363,10 +363,8 @@
 					    uint32_t log_file_seq,
 					    uoff_t log_file_offset)
 {
-	if (view->log_syncs == NULL) {
-		view->log_syncs = buffer_create_dynamic(default_pool,
-							128, (size_t)-1);
-	}
+	if (view->log_syncs == NULL)
+		view->log_syncs = buffer_create_dynamic(default_pool, 128);
 	buffer_append(view->log_syncs, &log_file_offset,
 		      sizeof(log_file_offset));
 	buffer_append(view->log_syncs, &log_file_seq, sizeof(log_file_seq));

Index: mail-index-view.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-view.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- mail-index-view.c	26 Sep 2004 14:15:54 -0000	1.21
+++ mail-index-view.c	8 Oct 2004 17:51:48 -0000	1.22
@@ -158,8 +158,7 @@
 				return;
 		}
 	} else {
-		view->map_refs =
-			buffer_create_dynamic(default_pool, 128, (size_t)-1);
+		view->map_refs = buffer_create_dynamic(default_pool, 128);
 	}
 
 	map->refcount++;

Index: mail-index.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.150
retrieving revision 1.151
diff -u -d -r1.150 -r1.151
--- mail-index.c	3 Oct 2004 16:32:59 -0000	1.150
+++ mail-index.c	8 Oct 2004 17:51:48 -0000	1.151
@@ -27,8 +27,7 @@
 	index->fd = -1;
 
 	index->extension_pool = pool_alloconly_create("extension", 256);
-	index->extensions =
-		buffer_create_dynamic(index->extension_pool, 64, (size_t)-1);
+	index->extensions = buffer_create_dynamic(index->extension_pool, 64);
 
 	index->mode = 0600;
 	index->gid = (gid_t)-1;
@@ -99,10 +98,9 @@
 		p_clear(map->extension_pool);
 	}
 
-	map->extensions = buffer_create_dynamic(map->extension_pool,
-						ext_size, (size_t)-1);
-	map->ext_id_map = buffer_create_dynamic(map->extension_pool,
-						ext_id_map_size, (size_t)-1);
+	map->extensions = buffer_create_dynamic(map->extension_pool, ext_size);
+	map->ext_id_map =
+		buffer_create_dynamic(map->extension_pool, ext_id_map_size);
 }
 
 uint32_t mail_index_map_lookup_ext(struct mail_index_map *map, const char *name)
@@ -471,8 +469,7 @@
 
 		if (map->buffer == NULL) {
 			map->buffer = buffer_create_dynamic(default_pool,
-							    records_size,
-							    (size_t)-1);
+							    records_size);
 		}
 
 		/* @UNSAFE */
@@ -582,8 +579,7 @@
 		map = i_new(struct mail_index_map, 1);
 		map->refcount = 1;
 		map->hdr_copy_buf =
-			buffer_create_dynamic(default_pool,
-					      sizeof(*map->hdr), (size_t)-1);
+			buffer_create_dynamic(default_pool, sizeof(*map->hdr));
 	} else if (MAIL_INDEX_MAP_IS_IN_MEMORY(map)) {
 		if (map->write_to_disk) {
 			/* we have modified this mapping and it's waiting to
@@ -651,7 +647,7 @@
 
 	mem_map = i_new(struct mail_index_map, 1);
 	mem_map->refcount = 1;
-	mem_map->buffer = buffer_create_dynamic(default_pool, size, (size_t)-1);
+	mem_map->buffer = buffer_create_dynamic(default_pool, size);
 	if (map->hdr->record_size == new_record_size)
 		buffer_append(mem_map->buffer, map->records, size);
 	else {
@@ -668,9 +664,8 @@
 	mem_map->records = buffer_get_modifyable_data(mem_map->buffer, NULL);
 	mem_map->records_count = map->records_count;
 
-	mem_map->hdr_copy_buf = buffer_create_dynamic(default_pool,
-						      map->hdr->header_size,
-						      (size_t)-1);
+	mem_map->hdr_copy_buf =
+		buffer_create_dynamic(default_pool, map->hdr->header_size);
 	buffer_append(mem_map->hdr_copy_buf, map->hdr, map->hdr->header_size);
 
 	hdr = buffer_get_modifyable_data(mem_map->hdr_copy_buf, NULL);

Index: mail-transaction-log.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-transaction-log.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- mail-transaction-log.c	3 Oct 2004 16:32:59 -0000	1.61
+++ mail-transaction-log.c	8 Oct 2004 17:51:48 -0000	1.62
@@ -727,8 +727,8 @@
 	}
 
 	if (file->buffer == NULL) {
-		file->buffer = buffer_create_dynamic(default_pool,
-						     LOG_PREFETCH, (size_t)-1);
+		file->buffer =
+			buffer_create_dynamic(default_pool, LOG_PREFETCH);
 		file->buffer_offset = offset;
 	}
 
@@ -978,10 +978,8 @@
 	uint32_t ext_id;
 	size_t pos;
 
-	if (t->ext_intros == NULL) {
-		t->ext_intros = buffer_create_dynamic(default_pool,
-						      128, (size_t)-1);
-	}
+	if (t->ext_intros == NULL)
+		t->ext_intros = buffer_create_dynamic(default_pool, 128);
 
 	t_push();
 	name = t_strndup((const char *)(intro+1), intro->name_size);
@@ -1138,7 +1136,7 @@
 	memset(&u, 0, sizeof(u));
 	u.new_file_seq = t->new_cache_file_seq;
 
-	buf = buffer_create_static(pool_datastack_create(), sizeof(u));
+	buf = buffer_create_static_hard(pool_datastack_create(), sizeof(u));
 	buffer_append(buf, &u, sizeof(u));
 	return buf;
 }
@@ -1153,7 +1151,7 @@
 
 	memset(&u, 0, sizeof(u));
 
-	buf = buffer_create_dynamic(pool_datastack_create(), 256, (size_t)-1);
+	buf = buffer_create_dynamic(pool_datastack_create(), 256);
 	for (offset = 0; offset <= sizeof(t->hdr_change); offset++) {
 		if (offset < sizeof(t->hdr_change) && t->hdr_mask[offset]) {
 			if (state == 0) {
@@ -1238,7 +1236,7 @@
 	}
 
 	/* and register them */
-	buf = buffer_create_dynamic(pool_datastack_create(), 128, (size_t)-1);
+	buf = buffer_create_dynamic(pool_datastack_create(), 128);
 	for (i = 0; i < size; i++) {
 		if (intro[i].name_size != 0) {
 			intro[i].name_size = strlen(ext[i].name);



More information about the dovecot-cvs mailing list