Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/install.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Install dependency

libCacheSim uses [camke](https://cmake.org/) build system and has a few dependencies:
libCacheSim uses [cmake](https://cmake.org/) build system and has a few dependencies:
[glib](https://developer.gnome.org/glib/)
[tcmalloc](https://github.com/google/tcmalloc),
[zstd](https://github.com/facebook/zstd).
Expand Down Expand Up @@ -70,4 +70,4 @@ brew install zstd
If still shows zstd not found after compilation, try
```bash
brew link zstd
```
```
16 changes: 14 additions & 2 deletions libCacheSim/bin/cachesim/cache_init.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

#include <strings.h>
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -105,9 +107,19 @@ static inline cache_t *create_cache(const char *trace_path,
} else {
const char *window_size = strstr(eviction_params, "window-size=");
if (window_size == NULL) {
char *new_params = malloc(strlen(eviction_params) + 20);
sprintf(new_params, "%s,window-size=0.01", eviction_params);
// Calculate exact size needed: original + ",window-size=0.01" + null
// terminator
size_t new_params_len =
strlen(eviction_params) + strlen(",window-size=0.01") + 1;
char *new_params = (char *)malloc(new_params_len);
if (new_params == NULL) {
ERROR("failed to allocate memory for new_params\n");
abort();
}
snprintf(new_params, new_params_len, "%s,window-size=0.01",
eviction_params);
cache = WTinyLFU_init(cc_params, new_params);
free(new_params); // Free the allocated memory
} else {
cache = WTinyLFU_init(cc_params, eviction_params);
}
Expand Down
Loading