Assemble dir/name+ext into a heap-allocated path. */
| 155 | |
| 156 | /* Assemble dir/name+ext into a heap-allocated path. */ |
| 157 | static char *build_path(const char *test_path, size_t dir_len, const char *name, size_t name_len, |
| 158 | const char *ext, size_t ext_len) { |
| 159 | char *result = malloc(dir_len + SKIP_ONE + name_len + ext_len + SKIP_ONE); |
| 160 | if (dir_len > 0) { |
| 161 | memcpy(result, test_path, dir_len); |
| 162 | result[dir_len] = '/'; |
| 163 | memcpy(result + dir_len + SKIP_ONE, name, name_len); |
| 164 | memcpy(result + dir_len + SKIP_ONE + name_len, ext, ext_len + SKIP_ONE); |
| 165 | } else { |
| 166 | memcpy(result, name, name_len); |
| 167 | memcpy(result + name_len, ext, ext_len + SKIP_ONE); |
| 168 | } |
| 169 | return result; |
| 170 | } |
| 171 | |
| 172 | /* Try to derive the production file path from a test file path. |
| 173 | * Returns heap-allocated string or NULL. Caller must free(). */ |