| 328 | } |
| 329 | |
| 330 | static void TwoQ_parse_params(cache_t *cache, |
| 331 | const char *cache_specific_params) { |
| 332 | TwoQ_params_t *params = (TwoQ_params_t *)(cache->eviction_params); |
| 333 | |
| 334 | char *params_str = strdup(cache_specific_params); |
| 335 | char *old_params_str = params_str; |
| 336 | |
| 337 | while (params_str != NULL && params_str[0] != '\0') { |
| 338 | /* different parameters are separated by comma, |
| 339 | * key and value are separated by = */ |
| 340 | char *key = strsep((char **)¶ms_str, "="); |
| 341 | char *value = strsep((char **)¶ms_str, ","); |
| 342 | |
| 343 | // skip the white space |
| 344 | while (params_str != NULL && *params_str == ' ') { |
| 345 | params_str++; |
| 346 | } |
| 347 | |
| 348 | if (strcasecmp(key, "Ain-size-ratio") == 0) { |
| 349 | params->Ain_size_ratio = strtod(value, NULL); |
| 350 | } else if (strcasecmp(key, "Aout-size-ratio") == 0) { |
| 351 | params->Aout_size_ratio = strtod(value, NULL); |
| 352 | } else if (strcasecmp(key, "print") == 0) { |
| 353 | printf("parameters: %s\n", TwoQ_current_params(params)); |
| 354 | exit(0); |
| 355 | } else { |
| 356 | ERROR("%s does not have parameter %s\n", cache->cache_name, key); |
| 357 | exit(1); |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | free(old_params_str); |
| 362 | } |
| 363 | |
| 364 | #ifdef __cplusplus |
| 365 | } |
no test coverage detected