gcc does not like snprintf(p, fmt, size). Used snprintf(p, size, fmt) instead