MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / TwoQ_parse_params

Function TwoQ_parse_params

libCacheSim/cache/eviction/TwoQ.c:330–362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328}
329
330static 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 **)&params_str, "=");
341 char *value = strsep((char **)&params_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}

Callers 1

TwoQ_initFunction · 0.85

Calls 1

TwoQ_current_paramsFunction · 0.85

Tested by

no test coverage detected