]> git.ozlabs.org Git - ccan-lca-2011.git/blobdiff - ccan/array/array.h
array: spelling fixes.
[ccan-lca-2011.git] / ccan / array / array.h
index c2efa3ce707d74678ca51e503e2e6b7644b62774..007c51b8f97e1095c2046245cbbc536687a7d282 100644 (file)
 //We do just fine by ourselves
 #define array_pop(array) ((array).item[--(array).size])
 
 //We do just fine by ourselves
 #define array_pop(array) ((array).item[--(array).size])
 
+#define array_for_t(var, array, type, ...) do {type *var=(void*)(array).item; size_t _r=(array).size, _i=0; for (;_r--;_i++, var++) { __VA_ARGS__ ;} } while(0)
+
+#define array_appends_t(array, type, ...) do {type __src[] = {__VA_ARGS__}; array_append_items(array, __src, sizeof(__src)/sizeof(*__src));} while(0)
 
 #if HAVE_TYPEOF==1
 
 #if HAVE_TYPEOF==1
-#define array_appends(array, ...) do {typeof((*(array).item)) __src[] = {__VA_ARGS__}; array_append_items(array, __src, sizeof(__src)/sizeof(*__src));} while(0)
+#define array_appends(array, ...) array_appends_t(array, typeof((*(array).item)), __VA_ARGS__)
 #define array_prepends(array, ...) do {typeof((*(array).item)) __src[] = {__VA_ARGS__}; array_prepend_items(array, __src, sizeof(__src)/sizeof(*__src));} while(0)
 #define array_prepends(array, ...) do {typeof((*(array).item)) __src[] = {__VA_ARGS__}; array_prepend_items(array, __src, sizeof(__src)/sizeof(*__src));} while(0)
-#define array_for(var, array, ...) do {typeof(*(array).item) *var=(void*)(array).item; size_t _r=(array).size, _i=0; for (;_r--;_i++, var++) { __VA_ARGS__ ;} } while(0)
+#define array_for(var, array, ...) array_for_t(var, array, typeof(*(array).item), __VA_ARGS__)
 #define array_rof(var, array, ...) do {typeof(*(array).item) *var=(void*)(array).item; size_t _i=(array).size, _r=0; var += _i; for (;_i--;_r++) { var--; __VA_ARGS__ ;} } while(0)
 #endif
 
 #define array_rof(var, array, ...) do {typeof(*(array).item) *var=(void*)(array).item; size_t _i=(array).size, _r=0; var += _i; for (;_i--;_r++) { var--; __VA_ARGS__ ;} } while(0)
 #endif
 
@@ -123,7 +126,7 @@ array_growalloc(array, newAlloc) sees if the array can currently hold newAlloc i
        if not, it increases the alloc to satisfy this requirement, allocating slack
        space to avoid having to reallocate for every size increment.
 
        if not, it increases the alloc to satisfy this requirement, allocating slack
        space to avoid having to reallocate for every size increment.
 
-array_from_string(array, str) copys a string to an array_char.
+array_from_string(array, str) copies a string to an array_char.
 
 array_push(array, item) pushes an item to the end of the array.
 array_pop_nocheck(array) pops it back out.  Be sure there is at least one item in the array before calling.
 
 array_push(array, item) pushes an item to the end of the array.
 array_pop_nocheck(array) pops it back out.  Be sure there is at least one item in the array before calling.