From d5828aae64db238fb60a1dfa1da581e5560b7f9d Mon Sep 17 00:00:00 2001 From: Tim Haines Date: Thu, 5 Jan 2023 13:30:11 -0600 Subject: [PATCH] Move Address_str into dynProcess.C It's only ever used there. --- common/src/Types.C | 19 ------------------- common/src/Types.h | 1 - dyninstAPI/src/dynProcess.C | 21 +++++++++++++++++++++ 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/common/src/Types.C b/common/src/Types.C index 94604619fd..70a7505a47 100644 --- a/common/src/Types.C +++ b/common/src/Types.C @@ -42,22 +42,3 @@ void Address_chk () { assert (sizeof(Address) == sizeof(void*)); } - -static const unsigned int _numaddrstrs=8; - // maximum number of addresses per outstanding printf! -static char _addrstr[_numaddrstrs][19]; // "0x"+16+'\0' - -// Format an address string according to the size of the Address type. -// Note that "%x" outputs incorrect/incomplete addresses, and that "%lx" -// or system-dependent "%p" (generally also requiring a typecast to (void*)) -// must be used instead! -char *Address_str (Address addr) -{ - static int i=0; - i=(i+1)%_numaddrstrs; - if (sizeof(Address) == sizeof(int)) - snprintf(_addrstr[i],19,"0x%08X",(unsigned int)addr); - else - snprintf(_addrstr[i],19,"0x%016lX",(unsigned long)addr); - return (_addrstr[i]); -} diff --git a/common/src/Types.h b/common/src/Types.h index 5b51c5da6b..01715b9706 100644 --- a/common/src/Types.h +++ b/common/src/Types.h @@ -94,7 +94,6 @@ typedef struct maps_entries { #include "common/h/util.h" COMMON_EXPORT void Address_chk (); -COMMON_EXPORT char *Address_str (Address addr); // NB: this is probably inappropriate for 64-bit addresses! inline unsigned hash_address(const Address& addr) { diff --git a/dyninstAPI/src/dynProcess.C b/dyninstAPI/src/dynProcess.C index 52002c461f..c343bf30b9 100644 --- a/dyninstAPI/src/dynProcess.C +++ b/dyninstAPI/src/dynProcess.C @@ -55,6 +55,27 @@ #include +namespace { + // maximum number of addresses per outstanding printf! + const unsigned int _numaddrstrs=8; + char _addrstr[_numaddrstrs][19]; // "0x"+16+'\0' + + // Format an address string according to the size of the Address type. + // Note that "%x" outputs incorrect/incomplete addresses, and that "%lx" + // or system-dependent "%p" (generally also requiring a typecast to (void*)) + // must be used instead! + char *Address_str (Address addr) + { + static int i=0; + i=(i+1)%_numaddrstrs; + if (sizeof(Address) == sizeof(int)) + snprintf(_addrstr[i],19,"0x%08X",(unsigned int)addr); + else + snprintf(_addrstr[i],19,"0x%016lX",(unsigned long)addr); + return (_addrstr[i]); + } +} + using namespace Dyninst::ProcControlAPI; using std::map; using std::vector;