diff --git a/xtandard.c b/xtandard.c index 35097be..ba8b6fe 100644 --- a/xtandard.c +++ b/xtandard.c @@ -67,6 +67,16 @@ void fatal_failure (int condition, char * message) { } } +void limit (int * value, int minimum, int maximum) { + if (* value <= minimum) { + * value = minimum; + } + + if (* value >= maximum) { + * value = maximum; + } +} + void * allocate (int size) { char * data = NULL; diff --git a/xtandard.h b/xtandard.h index 4eed4d0..c54b94d 100644 --- a/xtandard.h +++ b/xtandard.h @@ -80,6 +80,8 @@ extern void echo_byte (int); extern void fatal_failure (int, char *); +extern void limit (int *, int, int); + extern void * allocate (int); extern void * reallocate (void *, int); extern void * deallocate (void *);