samedi 26 juin 2021

C++, Check if Instance comes before Another in memory?

I have 2 pointers to nodes in C++:

MallocMetadata *first_node, MallocMetadata *second_node

How can I check if the first_node comes first in memory before second_node (Both in heap and by first I mean lower address).

  1. Is it true to use: if(first_node < second_node) ?

  2. Let's suppose I want to check if first_node's place in memory is a multiplication of 8 how to do this:

I tried:

assert(first_node%8 ==0);

But, doesn't compile and I get:

Invalid operands to binary expression ('MallocMetadata *' and 'int')

Aucun commentaire:

Enregistrer un commentaire