| 233 | } |
| 234 | |
| 235 | static void RandomLRU_parse_params(cache_t *cache, const char *cache_specific_params) { |
| 236 | RandomLRU_params_t *params = (RandomLRU_params_t *)(cache->eviction_params); |
| 237 | |
| 238 | char *params_str = strdup(cache_specific_params); |
| 239 | char *old_params_str = params_str; |
| 240 | char *end; |
| 241 | |
| 242 | while (params_str != NULL && params_str[0] != '\0') { |
| 243 | /* different parameters are separated by comma, |
| 244 | * key and value are separated by = */ |
| 245 | char *key = strsep((char **)¶ms_str, "="); |
| 246 | char *value = strsep((char **)¶ms_str, ","); |
| 247 | |
| 248 | // skip the white space |
| 249 | while (params_str != NULL && *params_str == ' ') { |
| 250 | params_str++; |
| 251 | } |
| 252 | |
| 253 | if (strcasecmp(key, "n-sample") == 0 || strcasecmp(key, "n-samples") == 0) { |
| 254 | params->n_samples = (int)strtol(value, &end, 0); |
| 255 | } else if (strcasecmp(key, "print") == 0) { |
| 256 | printf("current parameters: n-samples=%d\n", params->n_samples); |
| 257 | exit(0); |
| 258 | } else { |
| 259 | ERROR("%s does not have parameter %s\n", cache->cache_name, key); |
| 260 | exit(1); |
| 261 | } |
| 262 | } |
| 263 | free(old_params_str); |
| 264 | } |
| 265 | |
| 266 | #ifdef __cplusplus |
| 267 | } |