From d5d256b84fb6112960a37b3944c85b6b2bcf1125 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Thu, 26 Jun 2014 20:33:12 +0200 Subject: Replace COPY() macro use with assignment There seems to be no compelling reason to use COPY() or memcpy() --- src/hooks.cc | 2 +- src/monster2.cc | 4 ++-- src/object2.cc | 2 +- src/xtra2.cc | 3 +-- src/z-virt.h | 5 ----- 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/hooks.cc b/src/hooks.cc index ed8be7e9..0d89586a 100644 --- a/src/hooks.cc +++ b/src/hooks.cc @@ -162,7 +162,7 @@ static bool_ vprocess_hooks_return (int h_idx, const char *ret, const char *fmt, /* Push all args in the pile */ i = 0; - COPY(&real_ap, ap, va_list); + memcpy(&real_ap, ap, sizeof(va_list)); while (fmt[i]) { switch (fmt[i]) diff --git a/src/monster2.cc b/src/monster2.cc index c91cacfd..1a63e8a8 100644 --- a/src/monster2.cc +++ b/src/monster2.cc @@ -242,7 +242,7 @@ monster_race* race_info_idx(int r_idx, int ego) if (!ego) return r_ptr; /* Copy the base monster */ - COPY(nr_ptr, r_ptr, monster_race); + *nr_ptr = *r_ptr; /* Adjust the values */ for (i = 0; i < 4; i++) @@ -610,7 +610,7 @@ static void compact_monsters_aux(int i1, int i2) } /* Structure copy */ - COPY(&m_list[i2], &m_list[i1], monster_type); + m_list[i2] = m_list[i1]; /* Wipe the hole */ memset(&m_list[i1], 0, sizeof(monster_type)); diff --git a/src/object2.cc b/src/object2.cc index 9f4d872e..2a17e140 100644 --- a/src/object2.cc +++ b/src/object2.cc @@ -1908,7 +1908,7 @@ void object_wipe(object_type *o_ptr) void object_copy(object_type *o_ptr, object_type *j_ptr) { /* Copy the structure */ - COPY(o_ptr, j_ptr, object_type); + *o_ptr = *j_ptr; } diff --git a/src/xtra2.cc b/src/xtra2.cc index 4a2991bd..f74e54a5 100644 --- a/src/xtra2.cc +++ b/src/xtra2.cc @@ -5777,8 +5777,7 @@ void switch_subrace(int racem, bool_ copy_old) s32b old_title = race_mod_info[SUBRACE_SAVE].title; s32b old_desc = race_mod_info[SUBRACE_SAVE].desc; - COPY(&race_mod_info[SUBRACE_SAVE], &race_mod_info[p_ptr->pracem], player_race_mod); - + race_mod_info[SUBRACE_SAVE] = race_mod_info[p_ptr->pracem]; race_mod_info[SUBRACE_SAVE].title = old_title; race_mod_info[SUBRACE_SAVE].desc = old_desc; strcpy(race_mod_info[SUBRACE_SAVE].title + rmp_name, race_mod_info[p_ptr->pracem].title + rmp_name); diff --git a/src/z-virt.h b/src/z-virt.h index 952e2d86..04944d9d 100644 --- a/src/z-virt.h +++ b/src/z-virt.h @@ -68,11 +68,6 @@ extern "C" { (memset((char*)(P),0,SIZE(T))) -/* Load a thing of type T, at location P1, from another, at location P2 */ -#define COPY(P1,P2,T) \ - (memcpy((char*)(P1),(char*)(P2),SIZE(T))) - - /* Free an array of N things of type T at P, return NULL */ #define C_FREE(P,N,T) \ (rnfree(P,C_SIZE(N,T))) -- cgit v1.2.3