simple C utility functions