| 315 | } |
| 316 | |
| 317 | static void LRB_parse_params(cache_t *cache, |
| 318 | const char *cache_specific_params) { |
| 319 | LRB_params_t *params = (LRB_params_t *)cache->eviction_params; |
| 320 | char *params_str = strdup(cache_specific_params); |
| 321 | char *end; |
| 322 | |
| 323 | while (params_str != NULL && params_str[0] != '\0') { |
| 324 | /* different parameters are separated by comma, |
| 325 | * key and value are separated by = */ |
| 326 | char *key = strsep((char **)¶ms_str, "="); |
| 327 | char *value = strsep((char **)¶ms_str, ","); |
| 328 | |
| 329 | // skip the white space |
| 330 | while (params_str != NULL && *params_str == ' ') { |
| 331 | params_str++; |
| 332 | } |
| 333 | |
| 334 | if (strcasecmp(key, "objective") == 0) { |
| 335 | params->objective = strdup(value); |
| 336 | if (params->objective == NULL) { |
| 337 | ERROR("out of memory %s\n", strerror(errno)); |
| 338 | } |
| 339 | } else if (strcasecmp(key, "print") == 0) { |
| 340 | printf("current parameters: %s\n", LRB_current_params(cache, params)); |
| 341 | exit(0); |
| 342 | } else { |
| 343 | ERROR("%s does not have parameter %s\n", cache->cache_name, key); |
| 344 | exit(1); |
| 345 | } |
| 346 | } |
| 347 | free(params_str); |
| 348 | } |
| 349 | #ifdef __cplusplus |
| 350 | } |
| 351 | #endif |
no test coverage detected