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

Function LRB_parse_params

libCacheSim/cache/eviction/LRB/LRB_Interface.cpp:317–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

315}
316
317static void LRB_parse_params(cache_t *cache,
318 const char *cache_specific_params) {
319 LRB_params_t *params = (LRB_params_t *)cache->eviction_params;
320 char *params_str = strdup(cache_specific_params);
321 char *end;
322
323 while (params_str != NULL && params_str[0] != '\0') {
324 /* different parameters are separated by comma,
325 * key and value are separated by = */
326 char *key = strsep((char **)&params_str, "=");
327 char *value = strsep((char **)&params_str, ",");
328
329 // skip the white space
330 while (params_str != NULL && *params_str == ' ') {
331 params_str++;
332 }
333
334 if (strcasecmp(key, "objective") == 0) {
335 params->objective = strdup(value);
336 if (params->objective == NULL) {
337 ERROR("out of memory %s\n", strerror(errno));
338 }
339 } else if (strcasecmp(key, "print") == 0) {
340 printf("current parameters: %s\n", LRB_current_params(cache, params));
341 exit(0);
342 } else {
343 ERROR("%s does not have parameter %s\n", cache->cache_name, key);
344 exit(1);
345 }
346 }
347 free(params_str);
348}
349#ifdef __cplusplus
350}
351#endif

Callers 1

LRB_initFunction · 0.85

Calls 1

LRB_current_paramsFunction · 0.85

Tested by

no test coverage detected