Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve copying request #60

Merged
merged 1 commit into from
Feb 23, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions libCacheSim/cache/prefetch/Mithril.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ void Mithril_prefetch(cache_t *cache, const request_t *req) {
(Mithril_params->pf_list_size + 1);

request_t *new_req = my_malloc(request_t);
memcpy(new_req, req, sizeof(request_t));
copy_request(new_req, req);

if (prefetch_table_index) {
int i;
Expand Down Expand Up @@ -497,7 +497,7 @@ static inline bool _Mithril_check_sequential(cache_t *cache,
if (Mithril_params->sequential_K == 0) return FALSE;

request_t *new_req = my_malloc(request_t);
memcpy(new_req, req, sizeof(request_t));
copy_request(new_req, req);
bool is_sequential = TRUE;
gint sequential_K = Mithril_params->sequential_K;
if (sequential_K == -1) { /* when use AMP, this is -1 */
Expand Down
2 changes: 1 addition & 1 deletion libCacheSim/cache/prefetch/PG.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void PG_prefetch(cache_t *cache, const request_t *req) {
if (prefetch_list) {
GList *node = prefetch_list;
request_t *new_req = my_malloc(request_t);
memcpy(new_req, req, sizeof(request_t));
copy_request(new_req, req);
while (node) {
new_req->obj_id = GPOINTER_TO_INT(node->data);
new_req->obj_size =
Expand Down
4 changes: 2 additions & 2 deletions libCacheSim/include/libCacheSim/request.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static inline request_t *new_request(void) {
* @param req_dest
* @param req_src
*/
static inline void copy_request(request_t *req_dest, request_t *req_src) {
static inline void copy_request(request_t *req_dest, const request_t *req_src) {
memcpy(req_dest, req_src, sizeof(request_t));
}

Expand All @@ -96,7 +96,7 @@ static inline void copy_request(request_t *req_dest, request_t *req_src) {
* @param req
* @return
*/
static inline request_t *clone_request(request_t *req) {
static inline request_t *clone_request(const request_t *req) {
request_t *req_new = my_malloc(request_t);
copy_request(req_new, req);
return req_new;
Expand Down