Build the args string with the real project name substituted. Caller must free the returned string.
| 169 | // Build the args string with the real project name substituted. |
| 170 | // Caller must free the returned string. |
| 171 | static char *build_search_args(const char *project) { |
| 172 | const char *tmpl = SEARCH_ARGS; |
| 173 | const char *marker = "__PROJ__"; |
| 174 | const char *pos = strstr(tmpl, marker); |
| 175 | if (!pos || !project) { |
| 176 | return NULL; |
| 177 | } |
| 178 | size_t prefix_len = (size_t)(pos - tmpl); |
| 179 | size_t proj_len = strlen(project); |
| 180 | size_t suffix_len = strlen(pos + strlen(marker)); |
| 181 | size_t total = prefix_len + proj_len + suffix_len + 1; |
| 182 | char *out = malloc(total); |
| 183 | if (!out) { |
| 184 | return NULL; |
| 185 | } |
| 186 | memcpy(out, tmpl, prefix_len); |
| 187 | memcpy(out + prefix_len, project, proj_len); |
| 188 | memcpy(out + prefix_len + proj_len, pos + strlen(marker), suffix_len + 1); |
| 189 | return out; |
| 190 | } |
| 191 | |
| 192 | // repro_issue581_query_rss_stable |
| 193 | // |