[dovecot-cvs] dovecot/src/lib array.h,1.15,1.16

tss-movial at dovecot.org tss-movial at dovecot.org
Wed Jun 28 18:36:45 EEST 2006


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

Modified Files:
	array.h 
Log Message:
Added array_idx_clear().



Index: array.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/array.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- array.h	28 Jun 2006 13:10:33 -0000	1.15
+++ array.h	28 Jun 2006 15:36:42 -0000	1.16
@@ -205,6 +205,22 @@
 	_array_idx_set(&(array)->arr, idx, data); \
 	} STMT_END
 
+static inline void
+_array_idx_clear(struct array *array, unsigned int idx)
+{
+	size_t pos;
+
+	pos = idx * array->element_size;
+	if (pos > array->buffer->used) {
+		/* index doesn't exist yet, initialize with zero */
+		buffer_append_zero(array->buffer, pos - array->buffer->used);
+	} else {
+		buffer_write_zero(array->buffer, pos, array->element_size);
+	}
+}
+#define array_idx_clear(array, idx) \
+	_array_idx_clear(&(array)->arr, idx)
+
 static inline void *
 _array_append_space(struct array *array)
 {



More information about the dovecot-cvs mailing list