General multi purpose C functions