Introduce a generic clamp function to clean up some similarly duplicated code.
Change the modified parameter in the Clamp function to be a pointer.

Makes it easier to identify the one being modified.
Merge pull request #36 from lioncash/generic-clamp-function

Introduce a generic clamp function to clean up some of the various 'if-else' clamps throughout parts of the codebase.