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

Function SFIFO_parse_params

libCacheSim/cache/eviction/fifo/SFIFO.c:369–402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

367}
368
369static void SFIFO_parse_params(cache_t *cache,
370 const char *cache_specific_params) {
371 SFIFO_params_t *params = (SFIFO_params_t *)cache->eviction_params;
372 char *params_str = strdup(cache_specific_params);
373 char *old_params_str = params_str;
374 char *end;
375
376 while (params_str != NULL && params_str[0] != '\0') {
377 /* different parameters are separated by comma,
378 * key and value are separated by = */
379 char *key = strsep((char **)&params_str, "=");
380 char *value = strsep((char **)&params_str, ",");
381
382 // skip the white space
383 while (params_str != NULL && *params_str == ' ') {
384 params_str++;
385 }
386
387 if (strcasecmp(key, "n-seg") == 0) {
388 params->n_seg = (int)strtol(value, &end, 0);
389 if (strlen(end) > 2) {
390 ERROR("param parsing error, find string \"%s\" after number\n", end);
391 }
392
393 } else if (strcasecmp(key, "print") == 0) {
394 printf("current parameters: %s\n", SFIFO_current_params(params));
395 exit(0);
396 } else {
397 ERROR("%s does not have parameter %s\n", cache->cache_name, key);
398 exit(1);
399 }
400 }
401 free(old_params_str);
402}
403
404// ***********************************************************************
405// **** ****

Callers 1

SFIFO_initFunction · 0.85

Calls 1

SFIFO_current_paramsFunction · 0.85

Tested by

no test coverage detected