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

Function CAR_parse_params

libCacheSim/cache/eviction/CAR.c:485–517  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

483 }
484
485static void CAR_parse_params(cache_t *cache, const char *cache_specific_params) {
486 CAR_params_t *params = (CAR_params_t *)cache->eviction_params;
487 char *params_str = strdup(cache_specific_params);
488 char *old_params_str = params_str;
489 char *end;
490
491 while (params_str != NULL && params_str[0] != '\0') {
492 /* different parameters are separated by comma,
493 * key and value are separated by = */
494 char *key = strsep((char **)&params_str, "=");
495 char *value = strsep((char **)&params_str, ",");
496
497 // skip the white space
498 while (params_str != NULL && *params_str == ' ') {
499 params_str++;
500 }
501
502 if (strcasecmp(key, "p") == 0) {
503 params->p = (int)strtol(value, &end, 0);
504 if (strlen(end) > 2) {
505 ERROR("param parsing error, find string \"%s\" after number\n", end);
506 }
507 } else if (strcasecmp(key, "print") == 0) {
508 printf("current parameters: %s\n", CAR_current_params(cache, params));
509 exit(0);
510 } else {
511 ERROR("%s does not have parameter %s, example parameters %s\n", cache->cache_name, key,
512 CAR_current_params(cache, params));
513 exit(1);
514 }
515 }
516 free(old_params_str);
517}
518
519// ***********************************************************************
520// **** ****

Callers 1

CAR_initFunction · 0.85

Calls 1

CAR_current_paramsFunction · 0.85

Tested by

no test coverage detected