How does this check for anything??:
if ( size == 0 || size > SIZE_MAX ) {...
size is not given a type, but if it is a size_t, then the comparison is constant and if statements is always false, unless size == 0. The second part is useless, since the maximum size of size_t == SIZE_MAX.