1.1 --- a/src/cx/utils.h Thu Feb 02 20:25:34 2023 +0100 1.2 +++ b/src/cx/utils.h Wed Feb 08 18:56:58 2023 +0100 1.3 @@ -51,6 +51,15 @@ 1.4 */ 1.5 #define cx_for_n(varname, n) for (size_t varname = 0 ; (varname) < (n) ; (varname)++) 1.6 1.7 +/** 1.8 + * Convenience macro for swapping two pointers. 1.9 + */ 1.10 +#ifdef __cplusplus 1.11 +#define cx_swap_ptr(left, right) do {auto cx_tmp_swap_var = left; left = right; right = cx_tmp_swap_var;} while(0) 1.12 +#else 1.13 +#define cx_swap_ptr(left, right) do {void *cx_tmp_swap_var = left; left = right; right = cx_tmp_swap_var;} while(0) 1.14 +#endif 1.15 + 1.16 // cx_szmul() definition 1.17 1.18 #if (__GNUC__ >= 5 || defined(__clang__)) && !defined(CX_NO_SZMUL_BUILTIN)