about summary refs log tree commit diff
path: root/boot/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'boot/common.c')
-rw-r--r--boot/common.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/boot/common.c b/boot/common.c
index 3da5750..0524b3b 100644
--- a/boot/common.c
+++ b/boot/common.c
@@ -337,11 +337,10 @@ _slice_at(const struct _Slice* slice, uint index)
 #define slice_at(type, slice, index) ((type*)_slice_at(slice, index))
 
 // a macro for iterating over each element in an array.
-#define FOR_EACH_ARRAY(type, element_var, array_ptr, action) \
-    for (uint i = 0; i < array_length(array_ptr); ++i) {     \
-        type element_var = *array_at(type, array_ptr, i);    \
-        action;                                              \
-    }
+// for each iteration you get a pointer to the current element.
+#define FOR_EACH_ARRAY(type, element_var, array_ptr)   \
+    for (type* element_var = (type*)(array_ptr)->data; \
+         element_var < (type*)(array_ptr)->data + array_length(array_ptr); ++element_var)
 
 // the global string region.
 REGION(ascii, string)