C: use locale independent memcmp instead of strncmp