Add C_ARRAY_END(), returning a pointer to after the last element of an array.
Nicholas Clark [Fri, 28 May 2010 13:53:04 +0000 (14:53 +0100)]
Refactor the macro append_flags() in dump.c to use it.

dump.c
handy.h

diff --git a/dump.c b/dump.c
index aaeb344..89ee269 100644 (file)
--- a/dump.c
+++ b/dump.c
@@ -84,7 +84,7 @@ S_append_flags(pTHX_ SV *sv, U32 flags, const struct flag_to_name *start,
 }
 
 #define append_flags(sv, f, flags) \
-    S_append_flags(aTHX_ (sv), (f), (flags), (flags) + C_ARRAY_LENGTH(flags))
+    S_append_flags(aTHX_ (sv), (f), (flags), C_ARRAY_END(flags))
 
 
 #define Sequence PL_op_sequence
diff --git a/handy.h b/handy.h
index d17b8d3..3d2d46a 100644 (file)
--- a/handy.h
+++ b/handy.h
@@ -916,6 +916,7 @@ void Perl_mem_log_del_sv(const SV *sv, const char *filename, const int linenumbe
 #endif
 
 #define C_ARRAY_LENGTH(a)      (sizeof(a)/sizeof((a)[0]))
+#define C_ARRAY_END(a)         (a) + (sizeof(a)/sizeof((a)[0]))
 
 #ifdef NEED_VA_COPY
 # ifdef va_copy