From 951f9648d9654e942760eff8a89436f9632e3a3a Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Wed, 7 Jan 2026 08:49:16 +0100 Subject: [PATCH] utils/macros: add countof Rename ARR_COUNT to countof that is probably going to be defined by C2Y in stdcountof.h (as a macro for _Countof) for convenience. + keep the ARR_COUNT for compatibility --- src/utils/macros.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils/macros.h b/src/utils/macros.h index d096d98d7..3ee339200 100644 --- a/src/utils/macros.h +++ b/src/utils/macros.h @@ -3,7 +3,7 @@ * @author Martin Pulec */ /* - * Copyright (c) 2014-2025 CESNET + * Copyright (c) 2014-2026 CESNET, zájmové sdružení právnických osob * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -61,7 +61,10 @@ #define SWAP(a, b) do { b ^= a; a ^= b; b ^= a; } while (0) #define SWAP_PTR(a, b) do { void *tmp = (a); (a) = (b); (b) = tmp; } while(0) -#define ARR_COUNT(arr) (sizeof (arr) / sizeof (arr)[0]) +#ifndef countof // defined in C2Y stdcountof.h +#define countof(arr) (sizeof (arr) / sizeof (arr)[0]) +#endif +#define ARR_COUNT(arr) countof(arr) #undef MIN #define MIN(a,b) (((a)<(b))?(a):(b))