[dovecot-cvs] dovecot/src/lib array.h,1.3,1.4
cras at dovecot.org
cras at dovecot.org
Sun Mar 13 00:44:40 EET 2005
Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv28266
Modified Files:
array.h
Log Message:
#ifdefs were wrong, we need both __GNUC__ and DEBUG to do type checking.
Added new ARRAY_TYPE_CHECKS macro which can also be defined manually to
enable it.
Index: array.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/array.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- array.h 12 Mar 2005 22:38:06 -0000 1.3
+++ array.h 12 Mar 2005 22:44:37 -0000 1.4
@@ -36,6 +36,10 @@
}
*/
#if defined (DEBUG) && defined (__GNUC__)
+# define ARRAY_TYPE_CHECKS
+#endif
+
+#ifdef ARRAY_TYPE_CHECKS
# define ARRAY_DEFINE(name, array_type) name; array_type *name ## __ ## type
# define ARRAY_CREATE(array, pool, array_type, init_count) STMT_START { \
array_type *_array_tmp = *(array ## __ ## type); _array_tmp = NULL; \
@@ -96,7 +100,7 @@
{
buffer_append(array->buffer, data, count * array->element_size);
}
-#ifndef DEBUG
+#ifndef ARRAY_TYPE_CHECKS
# define array_append _array_append
#else
# define array_append(array, data, count) STMT_START { \
@@ -119,7 +123,7 @@
buffer_insert(array->buffer, idx * array->element_size,
data, count * array->element_size);
}
-#ifndef DEBUG
+#ifndef ARRAY_TYPE_CHECKS
# define array_insert _array_insert
#else
# define array_insert(array, idx, data, count) STMT_START { \
@@ -142,7 +146,7 @@
*count_r = array->buffer->used / array->element_size;
return array->buffer->data;
}
-#ifndef DEBUG
+#ifndef ARRAY_TYPE_CHECKS
# define array_get _array_get
#else
# define array_get(array, count) \
@@ -155,7 +159,7 @@
i_assert(idx * array->element_size < array->buffer->used);
return CONST_PTR_OFFSET(array->buffer->data, idx * array->element_size);
}
-#ifndef DEBUG
+#ifndef ARRAY_TYPE_CHECKS
# define array_idx _array_idx
#else
# define array_idx(array, idx) \
@@ -169,7 +173,7 @@
*count_r = array->buffer->used / array->element_size;
return buffer_get_modifyable_data(array->buffer, NULL);
}
-#ifndef DEBUG
+#ifndef ARRAY_TYPE_CHECKS
# define array_get_modifyable _array_get_modifyable
#else
# define array_get_modifyable(array, count) \
@@ -190,7 +194,7 @@
}
return buffer_get_space_unsafe(array->buffer, pos, array->element_size);
}
-#ifndef DEBUG
+#ifndef ARRAY_TYPE_CHECKS
# define array_modifyable_idx _array_modifyable_idx
#else
# define array_modifyable_idx(array, count) \
@@ -210,7 +214,7 @@
}
buffer_write(array->buffer, pos, data, array->element_size);
}
-#ifndef DEBUG
+#ifndef ARRAY_TYPE_CHECKS
# define array_idx_set _array_idx_set
#else
# define array_idx_set(array, idx, data) STMT_START { \
@@ -228,7 +232,7 @@
memset(data, 0, array->element_size);
return data;
}
-#ifndef DEBUG
+#ifndef ARRAY_TYPE_CHECKS
# define array_modifyable_append _array_modifyable_append
#else
# define array_modifyable_append(array) \
@@ -250,7 +254,7 @@
memset(data, 0, array->element_size);
return data;
}
-#ifndef DEBUG
+#ifndef ARRAY_TYPE_CHECKS
# define array_modifyable_insert _array_modifyable_insert
#else
# define array_modifyable_insert(array, idx) \
More information about the dovecot-cvs
mailing list