Skip to content
This repository was archived by the owner on Aug 11, 2023. It is now read-only.

Conversation

@DuncanMcBain
Copy link
Member

If the base address of the pointer mapper is 1, various tools will
complain about alignment, even though these are not "real" pointers.
Changing it to a user-specified variable, with a default highly-aligned
value, should fix this problem.

If the base address of the pointer mapper is 1, various tools will complain about alignment, even though these are not "real" pointers. Changing it to a user-specified variable, with a default highly-aligned value, should fix this problem.
@DuncanMcBain DuncanMcBain self-assigned this Aug 23, 2017
@DuncanMcBain DuncanMcBain requested review from Ruyk and jwlawson August 23, 2017 11:31
Copy link

@Ruyk Ruyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor change on the exception type.

PointerMapper(base_ptr_t baseAddress = 4096)
: m_pointerMap{}, m_freeList{}, m_baseAddress{baseAddress} {
if (m_baseAddress == 0) {
throw std::out_of_range(std::string("Base address cannot be zero"));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say an std::invalid_argument is more relevant

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're too right! I actually went onto cppreference, looked at the exceptions, thought to myself "this is invalid arg!" and wrote out of range because I'm a damn fool. Thanks!

Copy link
Contributor

@jwlawson jwlawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.
This doesn't ensure that all pointers will be aligned to some value (say if I first allocate 1 byte, then we are back to the original problem), but we can work around this by always allocating multiples of our desired alignment.

@DuncanMcBain DuncanMcBain merged commit 5d21399 into master Aug 23, 2017
@DuncanMcBain DuncanMcBain deleted the improvement/pmap-base-addr branch August 25, 2017 22:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

4 participants