Skip to content

Commit

Permalink
chore: improve copying request (#60)
Browse files Browse the repository at this point in the history
Signed-off-by: zztaki <zztaki@outlook.com>
  • Loading branch information
zztaki committed Feb 23, 2024
1 parent e075986 commit d27a7fd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions libCacheSim/cache/prefetch/Mithril.c
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
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
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

0 comments on commit d27a7fd

Please sign in to comment.