@@ -69,43 +69,50 @@ static inline cache_t *create_sim_cache(const char *eviction_algo,
6969 } else {
7070 const char *window_size = strstr (eviction_params, " window-size=" );
7171 if (window_size == NULL ) {
72- char *new_params = (char *)malloc (strlen (eviction_params) + 20 );
73- if (strlen (eviction_params) > 0 ) {
74- sprintf (new_params, " %s,window-size=0.01" , eviction_params);
72+ char dest[30 ];
73+ strncpy (dest, eviction_params, sizeof (dest) - 1 );
74+ dest[sizeof (dest) - 1 ] = ' \0 ' ;
75+ size_t param_len = strlen (dest);
76+ char *new_params = (char *)malloc (param_len + 20 );
77+ if (param_len > 0 ) {
78+ snprintf (new_params, param_len + 20 , " %s,window-size=0.01" ,
79+ eviction_params);
7580 } else { // if eviction_params is "", no comma is needed
76- sprintf (new_params, " window-size=0.01" );
81+ snprintf (new_params, 20 , " window-size=0.01" );
7782 }
7883 cache = WTinyLFU_init (cc_params, new_params);
84+ free (new_params);
7985 } else {
8086 cache = WTinyLFU_init (cc_params, eviction_params);
8187 }
8288 }
8389 } else if (strcasecmp (eviction_algo, " wtinyLFU" ) == 0 ) {
8490 cache = WTinyLFU_init (cc_params, eviction_params);
85- /* TODO(haocheng): add belady support, since we remove the trace path, format info needs to be passed in through another parameter */
86- // } else if (strcasecmp(eviction_algo, "belady") == 0 &&
87- // strcasestr(trace_path, "lcs") == NULL) {
88- // if (strcasestr(trace_path, "oracleGeneral") == NULL) {
89- // WARN("belady is only supported for oracleGeneral and lcs trace\n");
90- // WARN("to convert a trace to lcs format\n");
91- // WARN("./bin/traceConv input_trace trace_format output_trace\n");
92- // WARN("./bin/traceConv ../data/cloudPhysicsIO.txt txt\n");
93- // exit(1);
94- // }
95- // cache = Belady_init(cc_params, eviction_params);
91+ /* TODO(haocheng): add belady support, since we remove the trace path,
92+ * format info needs to be passed in through another parameter */
93+ // } else if (strcasecmp(eviction_algo, "belady") == 0 &&
94+ // strcasestr(trace_path, "lcs") == NULL) {
95+ // if (strcasestr(trace_path, "oracleGeneral") == NULL) {
96+ // WARN("belady is only supported for oracleGeneral and lcs trace\n");
97+ // WARN("to convert a trace to lcs format\n");
98+ // WARN("./bin/traceConv input_trace trace_format output_trace\n");
99+ // WARN("./bin/traceConv ../data/cloudPhysicsIO.txt txt\n");
100+ // exit(1);
101+ // }
102+ // cache = Belady_init(cc_params, eviction_params);
96103 } else if (strcasecmp (eviction_algo, " nop" ) == 0 ) {
97104 cache = nop_init (cc_params, eviction_params);
98- // } else if (strcasecmp(eviction_algo, "beladySize") == 0) {
99- // if (strcasestr(trace_path, "oracleGeneral") == NULL &&
100- // strcasestr(trace_path, "lcs") == NULL) {
101- // WARN("beladySize is only supported for oracleGeneral and lcs trace\n");
102- // WARN("to convert a trace to lcs format\n");
103- // WARN("./bin/traceConv input_trace trace_format output_trace\n");
104- // WARN("./bin/traceConv ../data/cloudPhysicsIO.txt txt\n");
105- // exit(1);
106- // }
107- // cc_params.hashpower = MAX(cc_params.hashpower - 8, 16);
108- // cache = BeladySize_init(cc_params, eviction_params);
105+ // } else if (strcasecmp(eviction_algo, "beladySize") == 0) {
106+ // if (strcasestr(trace_path, "oracleGeneral") == NULL &&
107+ // strcasestr(trace_path, "lcs") == NULL) {
108+ // WARN("beladySize is only supported for oracleGeneral and lcs
109+ // trace\n"); WARN("to convert a trace to lcs format\n");
110+ // WARN("./bin/traceConv input_trace trace_format output_trace\n");
111+ // WARN("./bin/traceConv ../data/cloudPhysicsIO.txt txt\n");
112+ // exit(1);
113+ // }
114+ // cc_params.hashpower = MAX(cc_params.hashpower - 8, 16);
115+ // cache = BeladySize_init(cc_params, eviction_params);
109116 } else if (strcasecmp (eviction_algo, " fifo-reinsertion" ) == 0 ||
110117 strcasecmp (eviction_algo, " clock" ) == 0 ||
111118 strcasecmp (eviction_algo, " second-chance" ) == 0 ) {
0 commit comments