[dovecot-cvs] dovecot/src/lib buffer.c,1.17,1.18 buffer.h,1.9,1.10

cras at dovecot.org cras at dovecot.org
Sun Sep 12 16:00:15 EEST 2004


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

Modified Files:
	buffer.c buffer.h 
Log Message:
Added buffer_write_zero and buffer_append_zero.



Index: buffer.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/buffer.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- buffer.c	5 Sep 2004 17:33:19 -0000	1.17
+++ buffer.c	12 Sep 2004 13:00:13 -0000	1.18
@@ -244,6 +244,22 @@
 	return size;
 }
 
+size_t buffer_write_zero(buffer_t *_buf, size_t pos, size_t data_size)
+{
+	struct real_buffer *buf = (struct real_buffer *)_buf;
+
+	if (!buffer_check_limits(buf, pos, &data_size, TRUE))
+		return 0;
+
+	memset(buf->w_buffer + pos, 0, data_size);
+	return data_size;
+}
+
+size_t buffer_append_zero(buffer_t *buf, size_t data_size)
+{
+	return buffer_write_zero(buf, buf->used, data_size);
+}
+
 size_t buffer_copy(buffer_t *_dest, size_t dest_pos,
 		   const buffer_t *_src, size_t src_pos, size_t copy_size)
 {

Index: buffer.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/buffer.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- buffer.h	18 Aug 2004 00:59:47 -0000	1.9
+++ buffer.h	12 Sep 2004 13:00:13 -0000	1.10
@@ -48,6 +48,10 @@
 /* Delete data from buffer, returns number of bytes deleted. */
 size_t buffer_delete(buffer_t *buf, size_t pos, size_t size);
 
+/* Fill buffer with zero bytes. */
+size_t buffer_write_zero(buffer_t *buf, size_t pos, size_t data_size);
+size_t buffer_append_zero(buffer_t *buf, size_t data_size);
+
 /* Copy data from buffer to another. The buffers may be same in which case
    it's internal copying, possibly with overlapping positions (ie. memmove()
    like functionality). copy_size may be set to (size_t)-1 to copy the rest of



More information about the dovecot-cvs mailing list