]> mj.ucw.cz Git - libucw.git/commitdiff
Added a useful macro for value clamping.
authorMartin Mares <mj@ucw.cz>
Tue, 20 Feb 2001 17:51:24 +0000 (17:51 +0000)
committerMartin Mares <mj@ucw.cz>
Tue, 20 Feb 2001 17:51:24 +0000 (17:51 +0000)
lib/index.h

index e4182c7c6ff34c5430b6301d420b5a4bb1f119f3..017cf7b2d58771e540c106efca38d879a631ba8b 100644 (file)
@@ -4,6 +4,8 @@
  *     (c) 2001 Martin Mares <mj@ucw.cz>
  */
 
+#define CLAMP(x,min,max) ({ int _t=x; (_t < min) ? min : (_t > max) ? max : _t; })
+
 /* Words */
 
 #define MAX_WORD_LEN           64