Add BMIN macro to tools.h

This commit is contained in:
Thomas Jensen 2023-06-26 22:04:35 +02:00
parent aef8c56eed
commit e2d5eab97b
No known key found for this signature in database
GPG Key ID: A4ACEE270D0FB7DB

View File

@ -26,13 +26,22 @@
#define BMAX(a, b) ({ /* return the larger value */ \ /** return the larger value */
#define BMAX(a, b) ({ \
__typeof__ (a) _a = (a); \ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \ __typeof__ (b) _b = (b); \
_a > _b ? _a : _b; \ _a > _b ? _a : _b; \
}) })
#define BFREE(p) { /* free memory and clear pointer */ \ /** return the smaller value */
#define BMIN(a, b) ({ \
__typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; \
})
/** free memory and clear pointer */
#define BFREE(p) { \
if (p) { \ if (p) { \
free((void *) (p)); \ free((void *) (p)); \
(p) = NULL; \ (p) = NULL; \