[dovecot-cvs] dovecot/src/lib-index mail-cache-transaction.c, 1.13, 1.14

cras at dovecot.org cras at dovecot.org
Thu Jul 15 15:26:34 EEST 2004


Update of /home/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv12824/lib-index

Modified Files:
	mail-cache-transaction.c 
Log Message:
Delay memory allocations for cache transaction. We don't always need it.



Index: mail-cache-transaction.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-cache-transaction.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- mail-cache-transaction.c	10 Jul 2004 11:16:05 -0000	1.13
+++ mail-cache-transaction.c	15 Jul 2004 12:26:31 -0000	1.14
@@ -45,10 +45,6 @@
 	ctx->cache = view->cache;
 	ctx->view = view;
 	ctx->trans = t;
-	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->reservations =
 		buffer_create_dynamic(system_pool, 256, (size_t)-1);
 
@@ -64,8 +60,10 @@
 	ctx->view->transaction = NULL;
 	ctx->view->trans_seq1 = ctx->view->trans_seq2 = 0;
 
-	buffer_free(ctx->cache_data);
-	buffer_free(ctx->cache_data_seq);
+	if (ctx->cache_data != NULL)
+		buffer_free(ctx->cache_data);
+	if (ctx->cache_data_seq != NULL)
+		buffer_free(ctx->cache_data_seq);
 	buffer_free(ctx->reservations);
 	i_free(ctx);
 }
@@ -421,6 +419,11 @@
 		buffer_append(ctx->cache_data_seq, &ctx->prev_seq,
 			      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);
 	}
 
 	memset(&new_rec, 0, sizeof(new_rec));



More information about the dovecot-cvs mailing list