Added side effect free min and max macros.
This commit is contained in:
@@ -72,12 +72,19 @@
|
|||||||
/**
|
/**
|
||||||
* Macro gives back larger of two values.
|
* Macro gives back larger of two values.
|
||||||
*/
|
*/
|
||||||
#define max(x,y) ((x) > (y) ? (x):(y))
|
#define max(x,y) ({ \
|
||||||
|
typeof(x) _x = (x); \
|
||||||
|
typeof(y) _y = (y); \
|
||||||
|
_x > _y ? _x : _y; })
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro gives back smaller of two values.
|
* Macro gives back smaller of two values.
|
||||||
*/
|
*/
|
||||||
#define min(x,y) ((x) < (y) ? (x):(y))
|
#define min(x,y) ({ \
|
||||||
|
typeof(x) _x = (x); \
|
||||||
|
typeof(y) _y = (y); \
|
||||||
|
_x < _y ? _x : _y; })
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call destructor of an object, if object != NULL
|
* Call destructor of an object, if object != NULL
|
||||||
|
|||||||
Reference in New Issue
Block a user