| 248 | } |
| 249 | |
| 250 | static char *activation_unique_path(const char *directory, const char *tag) { |
| 251 | uint64_t sequence = |
| 252 | atomic_fetch_add_explicit(&activation_unique_sequence, 1U, memory_order_relaxed) + 1U; |
| 253 | #ifdef _WIN32 |
| 254 | unsigned long process_id = (unsigned long)GetCurrentProcessId(); |
| 255 | #else |
| 256 | unsigned long process_id = (unsigned long)getpid(); |
| 257 | #endif |
| 258 | size_t directory_length = strlen(directory); |
| 259 | size_t needed = directory_length + strlen(tag) + 80U; |
| 260 | char *path = malloc(needed); |
| 261 | if (!path) { |
| 262 | return NULL; |
| 263 | } |
| 264 | /* Windows joins use the backslash: extended-length (\\\\?\\) directories |
| 265 | * reach this composer and that namespace performs no forward-slash |
| 266 | * translation. POSIX keeps the slash. */ |
| 267 | #ifdef _WIN32 |
| 268 | const char *separator = "\\"; |
| 269 | #else |
| 270 | const char *separator = "/"; |
| 271 | #endif |
| 272 | int written = |
| 273 | snprintf(path, needed, "%s%s.cbm-%s-%lu-%" PRIu64, directory, |
| 274 | directory[directory_length - 1U] == '/' || directory[directory_length - 1U] == '\\' |
| 275 | ? "" |
| 276 | : separator, |
| 277 | tag, process_id, sequence); |
| 278 | if (written <= 0 || (size_t)written >= needed) { |
| 279 | free(path); |
| 280 | return NULL; |
| 281 | } |
| 282 | return path; |
| 283 | } |
| 284 | |
| 285 | static bool activation_identity_equal(const activation_file_identity_t *left, |
| 286 | const activation_file_identity_t *right) { |
no outgoing calls
no test coverage detected