C utility functions